#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 */
struct event_loop {
  int dummy;
};

/* Variables and functions */
int STDIN_FILENO;
int /*<<< orphan*/ event_loop_stop(struct event_loop *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
void echo(struct event_loop *loop, int fd, int mask, void *data) {
  char s[256];
  if (fd == STDIN_FILENO) {
    scanf("%s", s);
    if (strcmp(s, "exit") == 0) {
      printf("bye!\n");
      event_loop_stop(loop);
    } else {
      printf("your input is: %s\n", s);
    }
  }
}


x86 assembly (clang, -O0):
<echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%eax
jne    11d1 <echo+0x91>
lea    -0x120(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b7 <echo+0x77>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <event_loop_stop@plt>
jmp    11cc <echo+0x8c>
lea    -0x120(%rbp),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d1 <echo+0x91>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<echo>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    0x2e7f(%rip),%rax
cmp    %esi,(%rax)
jne    11b5 <echo+0x65>
mov    %rdi,%r14
lea    0xe91(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a1 <echo+0x51>
lea    0xe73(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b5 <echo+0x65>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1060 <event_loop_stop@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.event_loop = type { i32 }
@STDIN_FILENO = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [6 x i8] c"bye!\0A\00"
@.str.3 = [19 x i8] c"your input is: %s\0A\00"
define void @echo(%struct.event_loop* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca %struct.event_loop*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [256 x i8]
store %struct.event_loop* %0, %struct.event_loop** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i32, i32* %6
%11 = load i32, i32* @STDIN_FILENO
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %4
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = load %struct.event_loop*, %struct.event_loop** %5
%22 = call i32 @event_loop_stop(%struct.event_loop* %21)
br label %26
23: ; preds = %13
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %19
br label %27
27: ; preds = %26, %4
ret void
}

LLVM IR (-O2):
%struct.event_loop = type { i32 }
@STDIN_FILENO = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"exit\00"
@.str.3 = [19 x i8] c"your input is: %s\0A\00"
@str = [5 x i8] c"bye!\00"
define void @echo(%struct.event_loop* %0, i32 %1, i32 %2, i8* nocapture readnone %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* @STDIN_FILENO
%8 = icmp eq i32 %7, %1
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%11 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%15 = call i32 @event_loop_stop(%struct.event_loop* %0)
br label %18
16: ; preds = %9
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %18
18: ; preds = %13, %16, %4
ret void
}