#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*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int test_init(int *argc, char **argv[]) {
  int i;
  char s[256];
  for (i = 0; i < (*argc); i++) {
    sprintf(s, "arg%d", i);
    if (strcmp((*argv)[i], s) != 0) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11a3 <test_init+0x83>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xea6(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1190 <test_init+0x70>
movl   $0x1,-0x4(%rbp)
jmp    11aa <test_init+0x8a>
jmp    1195 <test_init+0x75>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <test_init+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_init>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
cmpl   $0x0,(%rdi)
jle    117d <test_init+0x5d>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
lea    0xebc(%rip),%r12
mov    %rsp,%r13
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <sprintf@plt>
mov    (%r14),%rax
mov    (%rax,%rbx,8),%rdi
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1181 <test_init+0x61>
add    $0x1,%rbx
movslq (%r15),%rax
cmp    %rax,%rbx
jl     1150 <test_init+0x30>
xor    %eax,%eax
jmp    1186 <test_init+0x66>
mov    $0x1,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"arg%d\00"
define i32 @test_init(i32* nocapture %0, i8*** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %0
%6 = icmp sgt i32 %5, 0
br i1 %6, label %11, label %21
7: ; preds = %11
%8 = load i32, i32* %0
%9 = sext i32 %8 to i64
%10 = icmp slt i64 %20, %9
br i1 %10, label %11, label %21
11: ; preds = %2, %7
%12 = phi i64 [ %20, %7 ], [ 0, %2 ]
%13 = trunc i64 %12 to i32
%14 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i8**, i8*** %1
%16 = getelementptr inbounds i8*, i8** %15, i64 %12
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* %4)
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %12, 1
br i1 %19, label %7, label %21
21: ; preds = %11, %7, %2
%22 = phi i32 [ 0, %2 ], [ 0, %7 ], [ 1, %11 ]
ret i32 %22
}