#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 */
char *ReadLine(int);
int /*<<< orphan*/ _PrintUserLine(char *);
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ sendf(int, char *, char const *);
int /*<<< orphan*/ stderr;
int Dispense_ShowUser(int Socket, const char *Username) {
  char *buf;
  int responseCode, ret;
  sendf(Socket, "USER_INFO %s\n", Username);
  buf = ReadLine(Socket);
  responseCode = atoi(buf);
  switch (responseCode) {
  case 202:
    _PrintUserLine(buf);
    ret = 0;
    break;
  case 404:
    printf("Unknown user '%s'\n", Username);
    ret = 1;
    break;
  default:
    fprintf(stderr, "Unknown response code %i '%s'\n", responseCode, buf);
    ret = -1;
    break;
  }
  free(buf);
  return ret;
}


x86 assembly (clang, -O0):
<Dispense_ShowUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xe73(%rip),%rsi
call   1060 <sendf@plt>
mov    -0x4(%rbp),%edi
call   1080 <ReadLine@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0xca,%eax
je     11d3 <Dispense_ShowUser+0x63>
jmp    11c0 <Dispense_ShowUser+0x50>
mov    -0x24(%rbp),%eax
sub    $0x194,%eax
je     11e8 <Dispense_ShowUser+0x78>
jmp    1204 <Dispense_ShowUser+0x94>
mov    -0x18(%rbp),%rdi
call   1040 <_PrintUserLine@plt>
movl   $0x0,-0x20(%rbp)
jmp    1227 <Dispense_ShowUser+0xb7>
mov    -0x10(%rbp),%rsi
lea    0xe1b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x20(%rbp)
jmp    1227 <Dispense_ShowUser+0xb7>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe06(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Dispense_ShowUser>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xe80(%rip),%rsi
mov    %r14,%rdx
call   1060 <sendf@plt>
mov    %ebx,%edi
call   1080 <ReadLine@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <atoi@plt>
cmp    $0x194,%eax
je     11b4 <Dispense_ShowUser+0x44>
cmp    $0xca,%eax
jne    11ca <Dispense_ShowUser+0x5a>
mov    %rbx,%rdi
call   1040 <_PrintUserLine@plt>
xor    %ebp,%ebp
jmp    11e9 <Dispense_ShowUser+0x79>
lea    0xe53(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    $0x1,%ebp
jmp    11e9 <Dispense_ShowUser+0x79>
mov    0x2e0f(%rip),%rcx
mov    (%rcx),%edi
lea    0xe47(%rip),%rsi
mov    %eax,%edx
mov    %rbx,%rcx
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"USER_INFO %s\0A\00"
@.str.1 = [19 x i8] c"Unknown user '%s'\0A\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"Unknown response code %i '%s'\0A\00"
define i32 @Dispense_ShowUser(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i32, i32* %3
%9 = load i8*, i8** %4
%10 = call i32 @sendf(i32 %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %3
%12 = call i8* @ReadLine(i32 %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
switch i32 %15, label %22 [
i32 202, label %16
i32 404, label %19
]
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i32 @_PrintUserLine(i8* %17)
store i32 0, i32* %7
br label %27
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 1, i32* %7
br label %27
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i32, i32* %6
%25 = load i8*, i8** %5
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %24, i8* %25)
store i32 -1, i32* %7
br label %27
27: ; preds = %22, %19, %16
%28 = load i8*, i8** %5
%29 = call i32 @free(i8* %28)
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
@.str = [14 x i8] c"USER_INFO %s\0A\00"
@.str.1 = [19 x i8] c"Unknown user '%s'\0A\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"Unknown response code %i '%s'\0A\00"
define i32 @Dispense_ShowUser(i32 %0, i8* %1) {
%3 = tail call i32 @sendf(i32 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = tail call i8* @ReadLine(i32 %0)
%5 = tail call i32 @atoi(i8* %4)
switch i32 %5, label %10 [
i32 202, label %6
i32 404, label %8
]
6: ; preds = %2
%7 = tail call i32 @_PrintUserLine(i8* %4)
br label %13
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %5, i8* %4)
br label %13
13: ; preds = %10, %8, %6
%14 = phi i32 [ -1, %10 ], [ 1, %8 ], [ 0, %6 ]
%15 = tail call i32 @free(i8* %4)
ret i32 %14
}