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

/* Variables and functions */
int dns_add_serv(struct dns_ctx *, char *);
int dns_serv_count(struct dns_ctx *);
int dns_init_install_back_resolver(struct dns_ctx *ctx) {
  int res = dns_serv_count(ctx);
  if (res > 0)
    return res;
  res = dns_add_serv(ctx, "8.8.8.8");
  if (res < 0)
    return res;
  return dns_add_serv(ctx, "8.8.4.4");
}


x86 assembly (clang, -O0):
<dns_init_install_back_resolver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <dns_serv_count@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    114d <dns_init_install_back_resolver+0x2d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1188 <dns_init_install_back_resolver+0x68>
mov    -0x10(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1040 <dns_add_serv@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1175 <dns_init_install_back_resolver+0x55>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1188 <dns_init_install_back_resolver+0x68>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1040 <dns_add_serv@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dns_init_install_back_resolver>:
push   %rbx
mov    %rdi,%rbx
call   1030 <dns_serv_count@plt>
test   %eax,%eax
jle    112f <dns_init_install_back_resolver+0xf>
pop    %rbx
ret
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1040 <dns_add_serv@plt>
test   %eax,%eax
js     112d <dns_init_install_back_resolver+0xd>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <dns_add_serv@plt>

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

LLVM IR (-O2):
%struct.dns_ctx = type { i32 }
@.str = [8 x i8] c"8.8.8.8\00"
@.str.1 = [8 x i8] c"8.8.4.4\00"
define i32 @dns_init_install_back_resolver(%struct.dns_ctx* %0) {
%2 = tail call i32 @dns_serv_count(%struct.dns_ctx* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32 @dns_add_serv(%struct.dns_ctx* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = icmp slt i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @dns_add_serv(%struct.dns_ctx* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %4, %1, %7
%10 = phi i32 [ %8, %7 ], [ %2, %1 ], [ %5, %4 ]
ret i32 %10
}