#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int hostapd_main(int, char **);
int /*<<< orphan*/ stderr;
scalar_t__ strstr(char *, char *);
int wpa_supplicant_main(int, char **);
int main(int argc, char **argv) {
  bool restart = false;
  const char *prog = argv[0];
restart:
  if (strstr(argv[0], "hostapd"))
    return hostapd_main(argc, argv);
  else if (strstr(argv[0], "wpa_supplicant"))
    return wpa_supplicant_main(argc, argv);
  if (!restart && argc > 1) {
    argv++;
    argc--;
    restart = true;
    goto restart;
  }
  fprintf(stderr,
          "Invalid command.\nUsage: %s wpa_supplicant|hostapd [<arguments>]\n",
          prog);
  return 255;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8a(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1199 <main+0x59>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <hostapd_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1224 <main+0xe4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe61(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11ca <main+0x8a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <wpa_supplicant_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1224 <main+0xe4>
jmp    11cf <main+0x8f>
cmpl   $0x0,-0x14(%rbp)
jne    1204 <main+0xc4>
cmpl   $0x1,-0x8(%rbp)
jle    1204 <main+0xc4>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    1168 <main+0x28>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdff(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r13d
mov    (%rsi),%r14
lea    0xea5(%rip),%rsi
mov    %r14,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     1181 <main+0x41>
mov    %r13d,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <hostapd_main@plt>
mov    $0x1,%bpl
lea    0xe7d(%rip),%r15
lea    0xe6e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11dd <main+0x9d>
cmp    $0x2,%r13d
setge  %al
and    %al,%bpl
cmp    $0x1,%bpl
jne    11f6 <main+0xb6>
add    $0xffffffff,%r13d
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
mov    %r12,%rsi
call   1060 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11a0 <main+0x60>
jmp    1168 <main+0x28>
mov    %r13d,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <wpa_supplicant_main@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    $0xff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"hostapd\00"
@.str.1 = [15 x i8] c"wpa_supplicant\00"
@stderr = global i32 0
@.str.2 = [65 x i8] c"Invalid command.\0AUsage: %s wpa_supplicant|hostapd [<arguments>]\0A\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
store i8* %10, i8** %7
br label %11
11: ; preds = %38, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @hostapd_main(i32 %18, i8** %19)
store i32 %20, i32* %3
br label %47
21: ; preds = %11
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = load i32, i32* %4
%29 = load i8**, i8*** %5
%30 = call i32 @wpa_supplicant_main(i32 %28, i8** %29)
store i32 %30, i32* %3
br label %47
31: ; preds = %21
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
br i1 %34, label %43, label %35
35: ; preds = %32
%36 = load i32, i32* %4
%37 = icmp sgt i32 %36, 1
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i32 1
store i8** %40, i8*** %5
%41 = load i32, i32* %4
%42 = add nsw i32 %41, -1
store i32 %42, i32* %4
store i32 1, i32* %6
br label %11
43: ; preds = %35, %32
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %7
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i8* %45)
store i32 255, i32* %3
br label %47
47: ; preds = %43, %27, %17
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [8 x i8] c"hostapd\00"
@.str.1 = [15 x i8] c"wpa_supplicant\00"
@stderr = global i32 0
@.str.2 = [65 x i8] c"Invalid command.\0AUsage: %s wpa_supplicant|hostapd [<arguments>]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i64 @strstr(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %22, %2
%7 = phi i32 [ %0, %2 ], [ %24, %22 ]
%8 = phi i8** [ %1, %2 ], [ %23, %22 ]
%9 = tail call i32 @hostapd_main(i32 %7, i8** %8)
br label %31
10: ; preds = %2, %22
%11 = phi i1 [ false, %22 ], [ true, %2 ]
%12 = phi i8** [ %23, %22 ], [ %1, %2 ]
%13 = phi i32 [ %24, %22 ], [ %0, %2 ]
%14 = load i8*, i8** %12
%15 = tail call i64 @strstr(i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = tail call i32 @wpa_supplicant_main(i32 %13, i8** %12)
br label %31
19: ; preds = %10
%20 = icmp sgt i32 %13, 1
%21 = select i1 %11, i1 %20, i1 false
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = getelementptr inbounds i8*, i8** %12, i64 1
%24 = add nsw i32 %13, -1
%25 = load i8*, i8** %23
%26 = tail call i64 @strstr(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %10, label %6
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %31
31: ; preds = %28, %17, %6
%32 = phi i32 [ %9, %6 ], [ %18, %17 ], [ 255, %28 ]
ret i32 %32
}