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

/* Variables and functions */
int ctxsend(struct ddns3_ctx *, char *);
int recvline(struct ddns3_ctx *);
int recvlist(struct ddns3_ctx *);
int ddns3_ctx_list(struct ddns3_ctx *c) {
  int ret;
  ret = ctxsend(c, "LIST");
  if (ret < 0)
    return -1;
  ret = recvline(c);
  if (ret != 3)
    return -1;
  ret = recvlist(c);
  if (ret < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<ddns3_ctx_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <ctxsend@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1165 <ddns3_ctx_list+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <ddns3_ctx_list+0x80>
mov    -0x10(%rbp),%rdi
call   1050 <recvline@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
je     1187 <ddns3_ctx_list+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <ddns3_ctx_list+0x80>
mov    -0x10(%rbp),%rdi
call   1040 <recvlist@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11a9 <ddns3_ctx_list+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <ddns3_ctx_list+0x80>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ddns3_ctx_list>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec3(%rip),%rsi
call   1030 <ctxsend@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
js     1165 <ddns3_ctx_list+0x35>
mov    %rbx,%rdi
call   1050 <recvline@plt>
cmp    $0x3,%eax
jne    1165 <ddns3_ctx_list+0x35>
mov    %rbx,%rdi
call   1040 <recvlist@plt>
mov    %eax,%ebp
sar    $0x1f,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.ddns3_ctx = type { i32 }
@.str = [5 x i8] c"LIST\00"
define i32 @ddns3_ctx_list(%struct.ddns3_ctx* %0) {
%2 = alloca i32
%3 = alloca %struct.ddns3_ctx*
%4 = alloca i32
store %struct.ddns3_ctx* %0, %struct.ddns3_ctx** %3
%5 = load %struct.ddns3_ctx*, %struct.ddns3_ctx** %3
%6 = call i32 @ctxsend(%struct.ddns3_ctx* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %23
10: ; preds = %1
%11 = load %struct.ddns3_ctx*, %struct.ddns3_ctx** %3
%12 = call i32 @recvline(%struct.ddns3_ctx* %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 -1, i32* %2
br label %23
16: ; preds = %10
%17 = load %struct.ddns3_ctx*, %struct.ddns3_ctx** %3
%18 = call i32 @recvlist(%struct.ddns3_ctx* %17)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 -1, i32* %2
br label %23
22: ; preds = %16
store i32 0, i32* %2
br label %23
23: ; preds = %22, %21, %15, %9
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
%struct.ddns3_ctx = type { i32 }
@.str = [5 x i8] c"LIST\00"
define i32 @ddns3_ctx_list(%struct.ddns3_ctx* %0) {
%2 = tail call i32 @ctxsend(%struct.ddns3_ctx* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp slt i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 @recvline(%struct.ddns3_ctx* %0)
%6 = icmp eq i32 %5, 3
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32 @recvlist(%struct.ddns3_ctx* %0)
%9 = ashr i32 %8, 31
br label %10
10: ; preds = %7, %4, %1
%11 = phi i32 [ -1, %1 ], [ -1, %4 ], [ %9, %7 ]
ret i32 %11
}