#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 EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  printf("Number of args: %d, Args are:\n", argc);
  for (int i = 0; i < argc; ++i)
    printf("argv[%d]: %s\n", i, argv[i]);
  fprintf(stderr, "This message is sent to stderr.\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1185 <main+0x65>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <main+0x2e>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xecc(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
jle    1169 <main+0x49>
mov    %ebx,%r12d
lea    0xed4(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <main+0x30>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Number of args: %d, Args are:\0A\00"
@.str.1 = [14 x i8] c"argv[%d]: %s\0A\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"This message is sent to stderr.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %6
br label %9
9: ; preds = %21, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i32, i32* %6
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %19)
br label %21
21: ; preds = %13
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %9
24: ; preds = %9
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
@.str = [31 x i8] c"Number of args: %d, Args are:\0A\00"
@.str.1 = [14 x i8] c"argv[%d]: %s\0A\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"This message is sent to stderr.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %11
7: ; preds = %11, %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @EXIT_SUCCESS
ret i32 %10
11: ; preds = %5, %11
%12 = phi i64 [ 0, %5 ], [ %17, %11 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = trunc i64 %12 to i32
%16 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %14)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %6
br i1 %18, label %7, label %11
}