#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 *, size_t, ...);
int builtin_args(int argc, char *const argv[]) {
  size_t actual_argc;
  for (actual_argc = 0; argv[actual_argc] != NULL; actual_argc++)
    ;
  if (actual_argc == argc)
    printf("argc is correct: %d arguments\n", argc);
  else
    printf("argc differs from the actual number of arguments: %d vs %zu\n",
           argc, actual_argc);
  size_t min = actual_argc < argc ? actual_argc : argc;
  for (size_t i = 0; i < min; i++)
    printf("#%zu: \"%s\"\n", i, argv[i]);
  return 0;
}


x86 assembly (clang, -O0):
<builtin_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1150 <builtin_args+0x40>
jmp    113f <builtin_args+0x2f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1127 <builtin_args+0x17>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmp    %rcx,%rax
jne    1178 <builtin_args+0x68>
movslq -0x4(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118e <builtin_args+0x7e>
movslq -0x4(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmp    %rcx,%rax
jae    11ac <builtin_args+0x9c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11b4 <builtin_args+0xa4>
movslq -0x4(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1201 <builtin_args+0xf1>
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11c4 <builtin_args+0xb4>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_args>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpq   $0x0,0x8(%r15,%rbx,8)
lea    0x1(%rbx),%rbx
jne    1130 <builtin_args+0x20>
movslq %edi,%r14
cmp    %rbx,%r14
jne    1157 <builtin_args+0x47>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    116b <builtin_args+0x5b>
lea    0xec1(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %r14,%rbx
mov    %r14,%rax
cmovb  %rbx,%rax
test   %rax,%rax
je     11aa <builtin_args+0x9a>
cmp    %r14,%rbx
cmovb  %rbx,%r14
lea    0xed4(%rip),%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1190 <builtin_args+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"argc is correct: %d arguments\0A\00"
@.str.1 = [61 x i8] c"argc differs from the actual number of arguments: %d vs %zu\0A\00"
@.str.2 = [12 x i8] c"#%zu: \22%s\22\0A\00"
define i32 @builtin_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i64 0, i64* %5
br label %8
8: ; preds = %15, %2
%9 = load i8**, i8*** %4
%10 = load i64, i64* %5
%11 = getelementptr inbounds i8*, i8** %9, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %8
br label %15
15: ; preds = %14
%16 = load i64, i64* %5
%17 = add i64 %16, 1
store i64 %17, i64* %5
br label %8
18: ; preds = %8
%19 = load i64, i64* %5
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = icmp eq i64 %19, %21
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %25)
br label %32
27: ; preds = %18
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = load i64, i64* %5
%31 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i64 %29, i64 %30)
br label %32
32: ; preds = %27, %23
%33 = load i64, i64* %5
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = icmp ult i64 %33, %35
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = load i64, i64* %5
br label %42
39: ; preds = %32
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
br label %42
42: ; preds = %39, %37
%43 = phi i64 [ %38, %37 ], [ %41, %39 ]
store i64 %43, i64* %6
store i64 0, i64* %7
br label %44
44: ; preds = %55, %42
%45 = load i64, i64* %7
%46 = load i64, i64* %6
%47 = icmp ult i64 %45, %46
br i1 %47, label %48, label %58
48: ; preds = %44
%49 = load i64, i64* %7
%50 = load i8**, i8*** %4
%51 = load i64, i64* %7
%52 = getelementptr inbounds i8*, i8** %50, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %49, i8* %53)
br label %55
55: ; preds = %48
%56 = load i64, i64* %7
%57 = add i64 %56, 1
store i64 %57, i64* %7
br label %44
58: ; preds = %44
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"argc is correct: %d arguments\0A\00"
@.str.1 = [61 x i8] c"argc differs from the actual number of arguments: %d vs %zu\0A\00"
@.str.2 = [12 x i8] c"#%zu: \22%s\22\0A\00"
define i32 @builtin_args(i32 %0, i8** nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %8, %3 ]
%5 = getelementptr inbounds i8*, i8** %1, i64 %4
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
%8 = add i64 %4, 1
br i1 %7, label %9, label %3
9: ; preds = %3
%10 = sext i32 %0 to i64
%11 = icmp eq i64 %4, %10
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %4)
br label %16
14: ; preds = %9
%15 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i64 %10, i64 %4)
br label %16
16: ; preds = %14, %12
%17 = icmp ult i64 %4, %10
%18 = select i1 %17, i64 %4, i64 %10
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %21, %16
ret i32 0
21: ; preds = %16, %21
%22 = phi i64 [ %26, %21 ], [ 0, %16 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %22, i8* %24)
%26 = add nuw i64 %22, 1
%27 = icmp eq i64 %26, %18
br i1 %27, label %20, label %21
}