// #target: macos-x64
// #debuginfo: yes
module test;

fn void foo(String[] args)
{
	foreach (a : args)
	{
		int x = a.len;
	}
}

/* #expect: test.ll

define void @test.foo(ptr %0, i64 %1) #0 !dbg !8 {
entry:
  %args = alloca %"char[][]", align 8
  %.anon = alloca i64, align 8
  %a = alloca %"char[]", align 8
  %x = alloca i32, align 4
  store ptr %0, ptr %args, align 8
  %ptradd = getelementptr inbounds i8, ptr %args, i64 8
  store i64 %1, ptr %ptradd, align 8
  %ptradd1 = getelementptr inbounds i8, ptr %args, i64 8, !dbg !28
  %2 = load i64, ptr %ptradd1, align 8, !dbg !28
  store i64 0, ptr %.anon, align 8, !dbg !28
  br label %loop.cond, !dbg !28

loop.cond:                                        ; preds = %loop.body, %entry
  %3 = load i64, ptr %.anon, align 8, !dbg !28
  %lt = icmp ult i64 %3, %2, !dbg !28
  br i1 %lt, label %loop.body, label %loop.exit, !dbg !28

loop.body:                                        ; preds = %loop.cond
  %4 = load ptr, ptr %args, align 8, !dbg !34
  %5 = load i64, ptr %.anon, align 8, !dbg !34
  %ptroffset = getelementptr inbounds [16 x i8], ptr %4, i64 %5, !dbg !34
  call void @llvm.memcpy.p0.p0.i32(ptr align 8 %a, ptr align 8 %ptroffset, i32 16, i1 false), !dbg !34
  %ptradd2 = getelementptr inbounds i8, ptr %a, i64 8, !dbg !39
  %6 = load i64, ptr %ptradd2, align 8, !dbg !39
  %trunc = trunc i64 %6 to i32, !dbg !39
  store i32 %trunc, ptr %x, align 4, !dbg !39
  %7 = load i64, ptr %.anon, align 8, !dbg !28
  %addnuw = add nuw i64 %7, 1, !dbg !28
  store i64 %addnuw, ptr %.anon, align 8, !dbg !28
  br label %loop.cond, !dbg !28

loop.exit:                                        ; preds = %loop.cond
  ret void, !dbg !28
}

!24 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !11, baseType: !22, size: 64, align: 64, offset: 64)
!25 = !{}
!26 = !DILocalVariable(name: "args", arg: 1, scope: !8, file: !7, line: 3, type: !11)
!27 = !DILocation(line: 3, column: 22, scope: !8)
!28 = !DILocation(line: 5, column: 15, scope: !29)
!29 = distinct !DILexicalBlock(scope: !8, file: !7, line: 5, column: 2)
!30 = !DILocalVariable(name: ".temp", scope: !29, file: !7, line: 5, type: !22, align: 8)
!31 = !DILocalVariable(name: "a", scope: !32, file: !7, line: 5, type: !15, align: 8)
!32 = distinct !DILexicalBlock(scope: !29, file: !7, line: 6, column: 2)
!33 = !DILocation(line: 5, column: 11, scope: !32)
!34 = !DILocation(line: 5, column: 15, scope: !32)
!35 = !DILocalVariable(name: "x", scope: !36, file: !7, line: 7, type: !37, align: 4)
!36 = distinct !DILexicalBlock(scope: !32, file: !7, line: 6, column: 2)
!37 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!38 = !DILocation(line: 7, column: 7, scope: !36)
!39 = !DILocation(line: 7, column: 11, scope: !36)