#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ puts(char *);
int readField(int, char **, char);
scalar_t__ strcmpi(char *, char *);
int printReply(int sd) {
  int status;
  char *buf = NULL;
  if ((status = readField(sd, &buf, ':')) > 0) {
    printf("%c", strcmpi("OK", buf) == 0 ? '+' : '-');
    free(buf);
    if ((status = readField(sd, &buf, ':')) > 0) {
      puts(buf);
    }
    free(buf);
  }
  if (status < 0)
    status = -3;
  return status;
}


x86 assembly (clang, -O0):
<printReply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x3a,%edx
call   1060 <readField@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11eb <printReply+0x9b>
mov    -0x10(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1070 <strcmpi@plt>
mov    %rax,%rdx
mov    $0x2d,%eax
mov    $0x2b,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
lea    0xe55(%rip),%rdi
movsbl %al,%esi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x3a,%edx
call   1060 <readField@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11e2 <printReply+0x92>
mov    -0x10(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11fc <printReply+0xac>
movl   $0xfffffffd,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printReply>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    $0x3a,%edx
call   1060 <readField@plt>
test   %eax,%eax
jle    11ca <printReply+0x7a>
mov    (%rsp),%rsi
lea    0xe8a(%rip),%rdi
call   1070 <strcmpi@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,1),%esi
add    $0x2b,%esi
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x3a,%edx
call   1060 <readField@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11bf <printReply+0x6f>
mov    (%rsp),%rdi
call   1040 <puts@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
jmp    11cc <printReply+0x7c>
mov    %eax,%ebp
test   %ebp,%ebp
mov    $0xfffffffd,%eax
cmovns %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"OK\00"
define i32 @printReply(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i8* null, i8** %4
%5 = load i32, i32* %2
%6 = call i32 @readField(i32 %5, i8** %4, i8 signext 58)
store i32 %6, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %1
%9 = load i8*, i8** %4
%10 = call i64 @strcmpi(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 43, i32 45
%14 = trunc i32 %13 to i8
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %14)
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = load i32, i32* %2
%19 = call i32 @readField(i32 %18, i8** %4, i8 signext 58)
store i32 %19, i32* %3
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %8
%22 = load i8*, i8** %4
%23 = call i32 @puts(i8* %22)
br label %24
24: ; preds = %21, %8
%25 = load i8*, i8** %4
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %24, %1
%28 = load i32, i32* %3
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 -3, i32* %3
br label %31
31: ; preds = %30, %27
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"OK\00"
define i32 @printReply(i32 %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = call i32 @readField(i32 %0, i8** %2, i8 signext 58)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i64 @strcmpi(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8 43, i8 45
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %10)
%12 = load i8*, i8** %2
%13 = call i32 @free(i8* %12)
%14 = call i32 @readField(i32 %0, i8** %2, i8 signext 58)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %6
%17 = load i8*, i8** %2
%18 = call i32 @puts(i8* dereferenceable(1) %17)
br label %19
19: ; preds = %16, %6
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
br label %22
22: ; preds = %19, %1
%23 = phi i32 [ %14, %19 ], [ %4, %1 ]
%24 = icmp slt i32 %23, 0
%25 = select i1 %24, i32 -3, i32 %23
ret i32 %25
}