#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 */
char *strrchr(char *, char);
scalar_t__ strstr(char *, char *);
int udhcpc_main(int, char **);
int udhcpd_main(int, char **);
int main(int argc, char *argv[]) {
  int ret = 0;
  char *base = strrchr(argv[0], '/');
  if (strstr(base ? (base + 1) : argv[0], "dhcpd"))
    ret = udhcpd_main(argc, argv);
  else
    ret = udhcpc_main(argc, argv);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118e <main+0x4e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1199 <main+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11c7 <main+0x87>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <udhcpd_main@plt>
mov    %eax,-0x14(%rbp)
jmp    11d6 <main+0x96>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <udhcpc_main@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
mov    (%rsi),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rdi
test   %rax,%rax
cmove  %rbp,%rdi
lea    0xe94(%rip),%rsi
call   1060 <strstr@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
test   %rax,%rax
je     1185 <main+0x45>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <udhcpd_main@plt>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <udhcpc_main@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"dhcpd\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i8* @strrchr(i8* %10, i8 signext 47)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 1
br label %21
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
br label %21
21: ; preds = %17, %14
%22 = phi i8* [ %16, %14 ], [ %20, %17 ]
%23 = call i64 @strstr(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i32 @udhcpd_main(i32 %26, i8** %27)
store i32 %28, i32* %6
br label %33
29: ; preds = %21
%30 = load i32, i32* %4
%31 = load i8**, i8*** %5
%32 = call i32 @udhcpc_main(i32 %30, i8** %31)
store i32 %32, i32* %6
br label %33
33: ; preds = %29, %25
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
@.str = [6 x i8] c"dhcpd\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %3, i8* %6
%8 = tail call i64 @strstr(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @udhcpd_main(i32 %0, i8** %1)
br label %14
12: ; preds = %2
%13 = tail call i32 @udhcpc_main(i32 %0, i8** %1)
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ %11, %10 ], [ %13, %12 ]
ret i32 %15
}