#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, ...);
void printArgs(const int cnt, char *args[]) {
  printf("%s%d\n", "cnt = ", cnt);
  for (int i = 0; i < 20; i++) {
    if (args[i] != NULL)
      printf("%s\n", args[i]);
  }
}


x86 assembly (clang, -O0):
<printArgs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edx
lea    0xed7(%rip),%rdi
lea    0xed6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    1188 <printArgs+0x78>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1175 <printArgs+0x65>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117a <printArgs+0x6a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <printArgs+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArgs>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %edi,%edx
lea    0xedf(%rip),%rdi
lea    0xede(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed7(%rip),%r14
xor    %ebx,%ebx
jmp    114a <printArgs+0x3a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x14,%rbx
je     115f <printArgs+0x4f>
mov    (%r15,%rbx,8),%rsi
test   %rsi,%rsi
je     1140 <printArgs+0x30>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1140 <printArgs+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s%d\0A\00"
@.str.1 = [7 x i8] c"cnt = \00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @printArgs(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %6)
store i32 0, i32* %5
br label %8
8: ; preds = %26, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 20
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i8**, i8*** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = load i8**, i8*** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %18, %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %8
29: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s%d\0A\00"
@.str.1 = [7 x i8] c"cnt = \00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @printArgs(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %5
4: ; preds = %12
ret void
5: ; preds = %2, %12
%6 = phi i64 [ 0, %2 ], [ %13, %12 ]
%7 = getelementptr inbounds i8*, i8** %1, i64 %6
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %12
12: ; preds = %5, %10
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, 20
br i1 %14, label %4, label %5
}