#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 phonetics {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ print_number(struct phonetics *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
void listen(struct phonetics *phonetics) {
  char buffer[256] = "";
  while (1) {
    printf("> ");
    fgets(buffer, 256, stdin);
    buffer[strlen(buffer) - 1] = '\0';
    if (strcmp(buffer, "quit") == 0) {
      break;
    }
    print_number(phonetics, buffer);
  }
}


x86 assembly (clang, -O0):
<listen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e4c(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1060 <fgets@plt>
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11e3 <listen+0x83>
jmp    11f8 <listen+0x98>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1080 <print_number@plt>
jmp    1182 <listen+0x22>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<listen>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r15
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe2c(%rip),%r14
mov    0x2e0d(%rip),%r13
mov    %rsp,%rbx
lea    0xe1e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1235 <listen+0xe5>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <print_number@plt>
jmp    11f0 <listen+0xa0>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.phonetics = type { i32 }
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"quit\00"
define void @listen(%struct.phonetics* %0) {
%2 = alloca %struct.phonetics*
%3 = alloca [256 x i8]
store %struct.phonetics* %0, %struct.phonetics** %2
%4 = bitcast [256 x i8]* %3 to i8*
br label %5
5: ; preds = %1, %19
%6 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 256, i32 %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %13
store i8 0, i8* %14
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %5
br label %23
19: ; preds = %5
%20 = load %struct.phonetics*, %struct.phonetics** %2
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = call i32 @print_number(%struct.phonetics* %20, i8* %21)
br label %5
23: ; preds = %18
ret void
}

LLVM IR (-O2):
%struct.phonetics = type { i32 }
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"quit\00"
define void @listen(%struct.phonetics* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %14, %1
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %3, i32 256, i32 %6)
%8 = call i32 @strlen(i8* %3)
%9 = add nsw i32 %8, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %10
store i8 0, i8* %11
%12 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %4
%15 = call i32 @print_number(%struct.phonetics* %0, i8* %3)
br label %4
16: ; preds = %4
ret void
}