#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*/ enough_mem(char *);
int /*<<< orphan*/ free(char *);
char *ftp_readline(int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
char *strdup(char *);
int ftp_getrc(int fd, char **data) {
  char *line;
  char *tmp = 0;
  int response;
  while ((line = ftp_readline(fd))) {
    if (line[0] < '0' || line[0] > '9') {
      free(line);
      continue;
    }
    if (line[3] == ' ') {
      tmp = strdup(line);
      enough_mem(tmp);
      break;
    }
    free(line);
  }
  if (!line || !*line)
    return 0;
  sscanf(line, "%d ", &response);
  if (data) {
    *data = tmp;
  } else {
    free(tmp);
  }
  free(line);
  tmp = 0;
  if (response >= 100)
    return response;
  return 0;
}


x86 assembly (clang, -O0):
<ftp_getrc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <ftp_readline@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11e5 <ftp_getrc+0x95>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     119d <ftp_getrc+0x4d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    11ab <ftp_getrc+0x5b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1167 <ftp_getrc+0x17>
mov    -0x18(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x20,%eax
jne    11d7 <ftp_getrc+0x87>
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <enough_mem@plt>
jmp    11e5 <ftp_getrc+0x95>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1167 <ftp_getrc+0x17>
cmpq   $0x0,-0x18(%rbp)
je     11fd <ftp_getrc+0xad>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1209 <ftp_getrc+0xb9>
movl   $0x0,-0x4(%rbp)
jmp    126e <ftp_getrc+0x11e>
mov    -0x18(%rbp),%rdi
lea    0xdec(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <sscanf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1238 <ftp_getrc+0xe8>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1241 <ftp_getrc+0xf1>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
cmpl   $0x64,-0x24(%rbp)
jl     1267 <ftp_getrc+0x117>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    126e <ftp_getrc+0x11e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftp_getrc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
call   1060 <ftp_readline@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     11fa <ftp_getrc+0xaa>
mov    %rax,%rbx
jmp    1197 <ftp_getrc+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1060 <ftp_readline@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11fa <ftp_getrc+0xaa>
movzbl (%rbx),%eax
add    $0xc6,%al
cmp    $0xf5,%al
jbe    1180 <ftp_getrc+0x30>
cmpb   $0x20,0x3(%rbx)
jne    1180 <ftp_getrc+0x30>
mov    %rbx,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <enough_mem@plt>
cmpb   $0x0,(%rbx)
je     11fa <ftp_getrc+0xaa>
lea    0xe3b(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
test   %r14,%r14
je     11dc <ftp_getrc+0x8c>
mov    %rbp,(%r14)
jmp    11e4 <ftp_getrc+0x94>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%eax
xor    %r15d,%r15d
cmp    $0x64,%eax
cmovge %eax,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define i32 @ftp_getrc(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
br label %9
9: ; preds = %39, %25, %2
%10 = load i32, i32* %4
%11 = call i8* @ftp_readline(i32 %10)
store i8* %11, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %42
13: ; preds = %9
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp slt i32 %17, 48
br i1 %18, label %25, label %19
19: ; preds = %13
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sgt i32 %23, 57
br i1 %24, label %25, label %28
25: ; preds = %19, %13
%26 = load i8*, i8** %6
%27 = call i32 @free(i8* %26)
br label %9
28: ; preds = %19
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %39
34: ; preds = %28
%35 = load i8*, i8** %6
%36 = call i8* @strdup(i8* %35)
store i8* %36, i8** %7
%37 = load i8*, i8** %7
%38 = call i32 @enough_mem(i8* %37)
br label %42
39: ; preds = %28
%40 = load i8*, i8** %6
%41 = call i32 @free(i8* %40)
br label %9
42: ; preds = %34, %9
%43 = load i8*, i8** %6
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i8*, i8** %6
%47 = load i8, i8* %46
%48 = icmp ne i8 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %45, %42
store i32 0, i32* %3
br label %69
50: ; preds = %45
%51 = load i8*, i8** %6
%52 = call i32 @sscanf(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %8)
%53 = load i8**, i8*** %5
%54 = icmp ne i8** %53, null
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = load i8*, i8** %7
%57 = load i8**, i8*** %5
store i8* %56, i8** %57
br label %61
58: ; preds = %50
%59 = load i8*, i8** %7
%60 = call i32 @free(i8* %59)
br label %61
61: ; preds = %58, %55
%62 = load i8*, i8** %6
%63 = call i32 @free(i8* %62)
store i8* null, i8** %7
%64 = load i32, i32* %8
%65 = icmp sge i32 %64, 100
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = load i32, i32* %8
store i32 %67, i32* %3
br label %69
68: ; preds = %61
store i32 0, i32* %3
br label %69
69: ; preds = %68, %66, %49
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @ftp_getrc(i32 %0, i8** writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i8* @ftp_readline(i32 %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %36, label %7
7: ; preds = %2, %12
%8 = phi i8* [ %14, %12 ], [ %5, %2 ]
%9 = load i8, i8* %8
%10 = add i8 %9, -58
%11 = icmp ult i8 %10, -10
br i1 %11, label %12, label %16
12: ; preds = %7, %16
%13 = tail call i32 @free(i8* %8)
%14 = tail call i8* @ftp_readline(i32 %0)
%15 = icmp eq i8* %14, null
br i1 %15, label %36, label %7
16: ; preds = %7
%17 = getelementptr inbounds i8, i8* %8, i64 3
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 32
br i1 %19, label %20, label %12
20: ; preds = %16
%21 = tail call i8* @strdup(i8* %8)
%22 = tail call i32 @enough_mem(i8* %21)
%23 = load i8, i8* %8
%24 = icmp eq i8 %23, 0
br i1 %24, label %36, label %25
25: ; preds = %20
%26 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%27 = icmp eq i8** %1, null
br i1 %27, label %29, label %28
28: ; preds = %25
store i8* %21, i8** %1
br label %31
29: ; preds = %25
%30 = call i32 @free(i8* %21)
br label %31
31: ; preds = %29, %28
%32 = call i32 @free(i8* %8)
%33 = load i32, i32* %3
%34 = icmp sgt i32 %33, 99
%35 = select i1 %34, i32 %33, i32 0
br label %36
36: ; preds = %12, %2, %31, %20
%37 = phi i32 [ 0, %20 ], [ %35, %31 ], [ 0, %2 ], [ 0, %12 ]
ret i32 %37
}