#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 */
scalar_t__ strcmp(char *, char *);
char *get_udp_load_balancer_host(int argc, char **argv) {
  char *host;
  unsigned int i;
  for (i = 0; i < argc; ++i) {
    if (strcmp(argv[i], "--host") == 0) {
      host = argv[i + 1];
      return host;
    }
  }
  return "localhost";
}


x86 assembly (clang, -O0):
<get_udp_load_balancer_host>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1187 <get_udp_load_balancer_host+0x77>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1174 <get_udp_load_balancer_host+0x64>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1192 <get_udp_load_balancer_host+0x82>
jmp    1179 <get_udp_load_balancer_host+0x69>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1126 <get_udp_load_balancer_host+0x16>
lea    0xe79(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_udp_load_balancer_host>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xee7(%rip),%r14
test   %edi,%edi
je     1161 <get_udp_load_balancer_host+0x51>
mov    %rsi,%r12
mov    %edi,%r13d
xor    %ebx,%ebx
lea    0xecd(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbx,8),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     115c <get_udp_load_balancer_host+0x4c>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <get_udp_load_balancer_host+0x30>
jmp    1161 <get_udp_load_balancer_host+0x51>
mov    0x8(%r12,%rbx,8),%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"--host\00"
@.str.1 = [10 x i8] c"localhost\00"
define i8* @get_udp_load_balancer_host(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load i8**, i8*** %5
%22 = load i32, i32* %7
%23 = add i32 %22, 1
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
%26 = load i8*, i8** %25
store i8* %26, i8** %6
%27 = load i8*, i8** %6
store i8* %27, i8** %3
br label %33
28: ; preds = %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %7
%31 = add i32 %30, 1
store i32 %31, i32* %7
br label %8
32: ; preds = %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %33
33: ; preds = %32, %20
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
@.str = [7 x i8] c"--host\00"
@.str.1 = [10 x i8] c"localhost\00"
define i8* @get_udp_load_balancer_host(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %17
%7 = phi i64 [ 0, %4 ], [ %12, %17 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = add nuw i64 %7, 1
br i1 %11, label %13, label %17
13: ; preds = %6
%14 = and i64 %12, 4294967295
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
br label %19
17: ; preds = %6
%18 = icmp eq i64 %12, %5
br i1 %18, label %19, label %6
19: ; preds = %17, %2, %13
%20 = phi i8* [ %16, %13 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %17 ]
ret i8* %20
}