#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*/ displayStandardLine();
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ logging(char *, char *, char *);
int /*<<< orphan*/ parseLine(char *);
int /*<<< orphan*/ removeCarriageReturn(char *);
int /*<<< orphan*/ stdin;
void runProgram() {
  char buffer[512];
  displayStandardLine();
  while (fgets(buffer, 512, stdin) != NULL) {
    removeCarriageReturn(buffer);
    logging("DEBUG", "\"%s\" is read from stdin", buffer);
    parseLine(buffer);
    displayStandardLine();
  }
}


x86 assembly (clang, -O0):
<runProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
mov    $0x0,%al
call   1030 <displayStandardLine@plt>
lea    -0x200(%rbp),%rdi
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11c4 <runProgram+0x74>
lea    -0x200(%rbp),%rdi
call   1070 <removeCarriageReturn@plt>
lea    -0x200(%rbp),%rdx
lea    0xe60(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <logging@plt>
lea    -0x200(%rbp),%rdi
call   1060 <parseLine@plt>
mov    $0x0,%al
call   1030 <displayStandardLine@plt>
jmp    1162 <runProgram+0x12>
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runProgram>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
xor    %eax,%eax
call   1030 <displayStandardLine@plt>
mov    0x2e7c(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
mov    $0x200,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11db <runProgram+0x8b>
mov    %rsp,%rbx
lea    0xe74(%rip),%r14
lea    0xe73(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <removeCarriageReturn@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <logging@plt>
mov    %rbx,%rdi
call   1060 <parseLine@plt>
xor    %eax,%eax
call   1030 <displayStandardLine@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1040 <fgets@plt>
test   %rax,%rax
jne    11a0 <runProgram+0x50>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"DEBUG\00"
@.str.1 = [24 x i8] c"\22%s\22 is read from stdin\00"
define void @runProgram() {
%1 = alloca [512 x i8]
%2 = call i32 (...) @displayStandardLine()
br label %3
3: ; preds = %8, %0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %4, i32 512, i32 %5)
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%10 = call i32 @removeCarriageReturn(i8* %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%12 = call i32 @logging(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%14 = call i32 @parseLine(i8* %13)
%15 = call i32 (...) @displayStandardLine()
br label %3
16: ; preds = %3
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"DEBUG\00"
@.str.1 = [24 x i8] c"\22%s\22 is read from stdin\00"
define void @runProgram() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @displayStandardLine()
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %2, i32 512, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = call i32 @removeCarriageReturn(i8* %2)
%9 = call i32 @logging(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = call i32 @parseLine(i8* %2)
%11 = call i32 (...) @displayStandardLine()
%12 = load i32, i32* @stdin
%13 = call i32* @fgets(i8* %2, i32 512, i32 %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %7
15: ; preds = %7, %0
ret void
}