#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(int);
void readUntilMarker(char marker) {
  int ch;
  FILE *fp;
  fp = fopen("/home/caleb/Documents/genesis/data/me", "r");
  ch = getc(fp);
  while (ch != marker) {
    putchar(ch);
    ch = getc(fp);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<readUntilMarker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
lea    0xeab(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
movsbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
je     1199 <readUntilMarker+0x59>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x8(%rbp)
jmp    1171 <readUntilMarker+0x31>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readUntilMarker>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xeb4(%rip),%rdi
lea    0xed3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xchg   %ax,%ax
call   1060 <getc@plt>
cmp    %ebp,%eax
je     1175 <readUntilMarker+0x35>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
jmp    1160 <readUntilMarker+0x20>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"/home/caleb/Documents/genesis/data/me\00"
@.str.1 = [2 x i8] c"r\00"
define void @readUntilMarker(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32*
store i8 %0, i8* %2
%5 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %4
%6 = load i32*, i32** %4
%7 = call i32 @getc(i32* %6)
store i32 %7, i32* %3
br label %8
8: ; preds = %13, %1
%9 = load i32, i32* %3
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* %3
%15 = call i32 @putchar(i32 %14)
%16 = load i32*, i32** %4
%17 = call i32 @getc(i32* %16)
store i32 %17, i32* %3
br label %8
18: ; preds = %8
%19 = load i32*, i32** %4
%20 = call i32 @fclose(i32* %19)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"/home/caleb/Documents/genesis/data/me\00"
@.str.1 = [2 x i8] c"r\00"
define void @readUntilMarker(i8 signext %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @getc(i32* %2)
%4 = sext i8 %0 to i32
%5 = icmp eq i32 %3, %4
br i1 %5, label %11, label %6
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ %3, %1 ]
%8 = tail call i32 @putchar(i32 %7)
%9 = tail call i32 @getc(i32* %2)
%10 = icmp eq i32 %9, %4
br i1 %10, label %11, label %6
11: ; preds = %6, %1
%12 = tail call i32 @fclose(i32* %2)
ret void
}