#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 sprintf(char *, char *, char *, char *);
int ddns3_ctx_set(struct ddns3_ctx *c, char *handle, char *ip) {
  int ret;
  char buf[4096];
  ret = sprintf(buf, "SET %s %s", handle, ip);
  ret = ctxsend(c, buf);
  if (ret < 0)
    return -1;
  ret = recvline(c);
  if (ret != 1)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<ddns3_ctx_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x1030(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xea3(%rip),%rsi
call   1040 <sprintf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
call   1030 <ctxsend@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    118e <ddns3_ctx_set+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <ddns3_ctx_set+0x87>
mov    -0x10(%rbp),%rdi
call   1050 <recvline@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
je     11b0 <ddns3_ctx_set+0x80>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <ddns3_ctx_set+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ddns3_ctx_set>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xeb6(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <ctxsend@plt>
test   %eax,%eax
js     117a <ddns3_ctx_set+0x4a>
mov    %rbx,%rdi
call   1050 <recvline@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
setne  %al
neg    %eax
jmp    117f <ddns3_ctx_set+0x4f>
mov    $0xffffffff,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.ddns3_ctx = type { i32 }
@.str = [10 x i8] c"SET %s %s\00"
define i32 @ddns3_ctx_set(%struct.ddns3_ctx* %0, i8* %1, i8* %2) {
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%7 = call i32 @ctxsend(%struct.ddns3_ctx* %0, i8* %5)
%8 = icmp slt i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = call i32 @recvline(%struct.ddns3_ctx* %0)
%11 = icmp ne i32 %10, 1
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %9, %3
%14 = phi i32 [ -1, %3 ], [ %12, %9 ]
ret i32 %14
}