#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 atoi(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int i;
  static char *text[4] = {"foo", "bar", "42", "0"};
  for (i = 0; i < 4; ++i)
    printf("%s\n", text[i]);
  return atoi(text[2]) + atoi(text[3]);
}


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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1170 <main+0x50>
movslq -0x14(%rbp),%rcx
lea    0x2eee(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
mov    0x2ed9(%rip),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2ed2(%rip),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xef5(%rip),%rbx
lea    0xee1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x2a,%eax
pop    %rbx
ret

LLVM IR (-O0):
@main.text = internal global [4 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0)]
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [3 x i8] c"42\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [4 x i8] c"%s\0A\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
store i32 0, i32* %6
br label %7
7: ; preds = %16, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* @main.text, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %10
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %7
19: ; preds = %7
%20 = load i8*, i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @main.text, i64 0, i64 2)
%21 = call i32 @atoi(i8* %20)
%22 = load i8*, i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @main.text, i64 0, i64 3)
%23 = call i32 @atoi(i8* %22)
%24 = add nsw i32 %21, %23
ret i32 %24
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [3 x i8] c"42\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 42
}