void user_input(char *input) {
  if (strcmp(input, "END") == 0) {
    display("Stopping the CPU. Bye!\n");
    asm volatile("hlt");
  }
  display("You said: ");
  display(input);
  display("\n> ");
}


x86 assembly (clang, -O0):
<user_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1154 <user_input+0x34>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <display@plt>
hlt
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <display@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <display@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <display@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<user_input>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1143 <user_input+0x23>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1030 <display@plt>
hlt
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <display@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <display@plt>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <display@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"END\00"
@.str.1 = [24 x i8] c"Stopping the CPU. Bye!\0A\00"
@.str.2 = [11 x i8] c"You said: \00"
@.str.3 = [4 x i8] c"\0A> \00"
define void @user_input(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = load i8*, i8** %2
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* %10)
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"END\00"
@.str.1 = [24 x i8] c"Stopping the CPU. Bye!\0A\00"
@.str.2 = [11 x i8] c"You said: \00"
@.str.3 = [4 x i8] c"\0A> \00"
define void @user_input(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
tail call void asm sideeffect "hlt", "~{dirflag},~{fpsr},~{flags}"()
br label %6
6: ; preds = %4, %1
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* %0)
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @display to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret void
}