#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write(int, char *, int);
int main(int argv, char **argc) {
  int i;
  write(1, "raw write\n\r", 11);
  fputs("fputs\n\r", stdout);
  printf("printf\n\r");
  printf("argv: %d\n\r", argv);
  for (i = 0; i < argv; i++) {
    printf("argc[%d]:%s\n\r", i, argc[i]);
    fputs(argc[i], stdout);
  }
  return (0);
}


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    $0x1,%edi
lea    0xeae(%rip),%rsi
mov    $0xb,%edx
call   1030 <write@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
lea    0xea0(%rip),%rdi
call   1050 <fputs@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e8 <main+0xb8>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1197 <main+0x67>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xebc(%rip),%rsi
mov    $0x1,%edi
mov    $0xb,%edx
call   1030 <write@plt>
mov    0x2e86(%rip),%r15
mov    (%r15),%esi
lea    0xea8(%rip),%rdi
call   1050 <fputs@plt>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11c5 <main+0x95>
mov    %ebp,%r12d
lea    0xe93(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx,%rbp,8),%rdi
mov    (%r15),%esi
call   1050 <fputs@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11a0 <main+0x70>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"raw write\0A\0D\00"
@.str.1 = [8 x i8] c"fputs\0A\0D\00"
@stdout = global i32 0
@.str.2 = [9 x i8] c"printf\0A\0D\00"
@.str.3 = [11 x i8] c"argv: %d\0A\0D\00"
@.str.4 = [14 x i8] c"argc[%d]:%s\0A\0D\00"
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 = call i32 @write(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%8 = load i32, i32* @stdout
%9 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %11)
store i32 0, i32* %6
br label %13
13: ; preds = %32, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %35
17: ; preds = %13
%18 = load i32, i32* %6
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %18, i8* %23)
%25 = load i8**, i8*** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = load i32, i32* @stdout
%31 = call i32 @fputs(i8* %29, i32 %30)
br label %32
32: ; preds = %17
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %13
35: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"raw write\0A\0D\00"
@.str.1 = [8 x i8] c"fputs\0A\0D\00"
@stdout = global i32 0
@.str.2 = [9 x i8] c"printf\0A\0D\00"
@.str.3 = [11 x i8] c"argv: %d\0A\0D\00"
@.str.4 = [14 x i8] c"argc[%d]:%s\0A\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%4 = load i32, i32* @stdout
%5 = tail call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %20, %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*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %15, i8* %14)
%17 = load i8*, i8** %13
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputs(i8* %17, i32 %18)
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %11, %2
ret i32 0
}