#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 */
char getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char, ...);
int main(int argc, char **argv) {
  char *breaking_internets;
  breaking_internets = (char *)malloc(50);
  unsigned char cur = 0;
  while (breaking_internets[cur] != 'f') {
    cur++;
    breaking_internets[cur] = getchar();
    breaking_internets[cur + 1] = '\0';
    printf("breaking_internets[%d]=%c \n", cur, *breaking_internets);
  }
  printf("here is the code: %c \n", *breaking_internets);
  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    $0x32,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movzbl -0x19(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x66,%eax
je     11bb <main+0x8b>
mov    -0x19(%rbp),%al
add    $0x1,%al
mov    %al,-0x19(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movzbl -0x19(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
movzbl -0x19(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%edx
lea    0xe54(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1158 <main+0x28>
mov    -0x18(%rbp),%rax
lea    0xe56(%rip),%rdi
movsbl (%rax),%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x32,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    $0x66,%al
cmpb   $0x66,(%r15)
je     1197 <main+0x67>
mov    $0x1,%bl
lea    0xeaa(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
movzbl %bl,%r12d
mov    %al,(%r15,%r12,1)
movb   $0x0,0x1(%r15,%r12,1)
movsbl (%r15),%edx
movsbl %r12b,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12d,%ebx
add    $0x1,%bl
cmpb   $0x66,(%r15,%r12,1)
jne    1160 <main+0x30>
mov    (%r15),%al
movsbl %al,%esi
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"breaking_internets[%d]=%c \0A\00"
@.str.1 = [23 x i8] c"here is the code: %c \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @malloc(i32 50)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %6
store i8 0, i8* %7
br label %10
10: ; preds = %18, %2
%11 = load i8*, i8** %6
%12 = load i8, i8* %7
%13 = zext i8 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 102
br i1 %17, label %18, label %37
18: ; preds = %10
%19 = load i8, i8* %7
%20 = add i8 %19, 1
store i8 %20, i8* %7
%21 = call signext i8 (...) @getchar()
%22 = load i8*, i8** %6
%23 = load i8, i8* %7
%24 = zext i8 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
%26 = load i8*, i8** %6
%27 = load i8, i8* %7
%28 = zext i8 %27 to i32
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %26, i64 %30
store i8 0, i8* %31
%32 = load i8, i8* %7
%33 = load i8*, i8** %6
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 signext %32, i32 %35)
br label %10
37: ; preds = %10
%38 = load i8*, i8** %6
%39 = load i8, i8* %38
%40 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8 signext %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"breaking_internets[%d]=%c \0A\00"
@.str.1 = [23 x i8] c"here is the code: %c \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 50)
%4 = inttoptr i64 %3 to i8*
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 102
br i1 %6, label %22, label %7
7: ; preds = %2, %7
%8 = phi i8 [ %9, %7 ], [ 0, %2 ]
%9 = add i8 %8, 1
%10 = tail call signext i8 (...) @getchar()
%11 = zext i8 %9 to i64
%12 = getelementptr inbounds i8, i8* %4, i64 %11
store i8 %10, i8* %12
%13 = add nuw nsw i64 %11, 1
%14 = getelementptr inbounds i8, i8* %4, i64 %13
store i8 0, i8* %14
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 signext %9, i32 %16)
%18 = load i8, i8* %12
%19 = icmp eq i8 %18, 102
br i1 %19, label %20, label %7
20: ; preds = %7
%21 = load i8, i8* %4
br label %22
22: ; preds = %20, %2
%23 = phi i8 [ %21, %20 ], [ 102, %2 ]
%24 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8 signext %23)
ret i32 0
}