#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 *, ...);
int main(int argc, char const *argv[]) {
  char string[] = "Hello World\n";
  int i;
  printf("%s", string);
  for (i = 0; string[i] != '\0'; ++i) {
    printf("%c", string[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xed1(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xecc(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x1d(%rbp),%rsi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x1d(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1193 <main+0x83>
movslq -0x24(%rbp),%rax
movsbl -0x1d(%rbp,%rax,1),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115c <main+0x4c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0xa646c726f5720,%rax
mov    %rax,0x5(%rsp)
movabs $0x6f57206f6c6c6548,%rax
20 57 6f
mov    %rax,(%rsp)
lea    0xec4(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     1173 <main+0x53>
lea    0x1(%rsp),%rbx
nop
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.string = [13 x i8] c"Hello World\0A\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [13 x i8]* %6 to i8*
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 0, i32* %7
br label %11
11: ; preds = %25, %2
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %11
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %18
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %11
28: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.string = [13 x i8] c"Hello World\0A\00"
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [13 x i8]
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %13, %8 ], [ 0, %2 ]
%10 = phi i8 [ %15, %8 ], [ %6, %2 ]
%11 = sext i8 %10 to i32
%12 = call i32 @putchar(i32 %11)
%13 = add nuw i64 %9, 1
%14 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %8, %2
ret i32 0
}