#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;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ leaking();
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int i;
  char s[5];
  char c;
  char *t;
  printf("start\n");
  for (i = 0; i < 6; i++) {
    s[i] = 0;
  }
  s[c] = 4;
  while (1) {
    leaking();
    c++;
    s[c] = 256;
  }
  t = (char *)calloc(4, sizeof(char));
  t[164] = 7;
  t[5] = 8;
  printf("done\n");
  return EXIT_SUCCESS;
}


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)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    116a <main+0x4a>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x19(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <main+0x29>
movsbq -0x1a(%rbp),%rax
movb   $0x4,-0x19(%rbp,%rax,1)
mov    $0x0,%al
call   1040 <leaking@plt>
mov    -0x1a(%rbp),%al
add    $0x1,%al
mov    %al,-0x29(%rbp)
mov    %al,-0x1a(%rbp)
movsbq -0x1a(%rbp),%rax
movb   $0x0,-0x19(%rbp,%rax,1)
jmp    1174 <main+0x54>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
nopl   (%rax)
xor    %eax,%eax
call   1040 <leaking@plt>
jmp    1130 <main+0x10>

LLVM IR (-O0):
@.str = [7 x i8] c"start\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
%7 = alloca [5 x i8]
%8 = alloca i8
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %11
11: ; preds = %18, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %14
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %11
21: ; preds = %11
%22 = load i8, i8* %8
%23 = sext i8 %22 to i64
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 %23
store i8 4, i8* %24
br label %25
25: ; preds = %21, %25
%26 = call i32 (...) @leaking()
%27 = load i8, i8* %8
%28 = add i8 %27, 1
store i8 %28, i8* %8
%29 = load i8, i8* %8
%30 = sext i8 %29 to i64
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 %30
store i8 0, i8* %31
br label %25
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [6 x i8] c"start\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %2, %4
%5 = tail call i32 (...) @leaking()
br label %4
}