#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*/ SIGTERM;
int atoi(int /*<<< orphan*/);
int getopt(int, char **, char *);
int kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ show_usage();
int /*<<< orphan*/ sleep(int);
extern int reboot_main(int argc, char **argv) {
  int delay = 0;
  int rc;
  while ((rc = getopt(argc, argv, "d:")) > 0) {
    switch (rc) {
    case 'd':
      delay = atoi(optarg);
      break;
    default:
      show_usage();
      break;
    }
  }
  if (delay > 0)
    sleep(delay);
  return (kill(1, SIGTERM));
}


x86 assembly (clang, -O0):
<reboot_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    11b8 <reboot_main+0x68>
mov    -0x18(%rbp),%eax
sub    $0x64,%eax
jne    11ac <reboot_main+0x5c>
jmp    1196 <reboot_main+0x46>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    11b3 <reboot_main+0x63>
mov    $0x0,%al
call   1040 <show_usage@plt>
jmp    1166 <reboot_main+0x16>
cmpl   $0x0,-0x14(%rbp)
jle    11ca <reboot_main+0x7a>
mov    -0x14(%rbp),%edi
call   1070 <sleep@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1030 <kill@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reboot_main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe9c(%rip),%rdx
call   1050 <getopt@plt>
test   %eax,%eax
jle    11b8 <reboot_main+0x68>
mov    0x2e84(%rip),%r12
lea    0xe85(%rip),%r14
xor    %r15d,%r15d
jmp    1198 <reboot_main+0x48>
xor    %eax,%eax
call   1040 <show_usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
test   %eax,%eax
jle    11ab <reboot_main+0x5b>
cmp    $0x64,%eax
jne    1180 <reboot_main+0x30>
mov    (%r12),%edi
call   1060 <atoi@plt>
mov    %eax,%r15d
jmp    1187 <reboot_main+0x37>
test   %r15d,%r15d
jle    11b8 <reboot_main+0x68>
mov    %r15d,%edi
call   1070 <sleep@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <kill@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"d:\00"
@optarg = global i32 0
@SIGTERM = global i32 0
define i32 @reboot_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
br label %7
7: ; preds = %19, %2
%8 = load i32, i32* %3
%9 = load i8**, i8*** %4
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %17 [
i32 100, label %14
]
14: ; preds = %12
%15 = load i32, i32* @optarg
%16 = call i32 @atoi(i32 %15)
store i32 %16, i32* %5
br label %19
17: ; preds = %12
%18 = call i32 (...) @show_usage()
br label %19
19: ; preds = %17, %14
br label %7
20: ; preds = %7
%21 = load i32, i32* %5
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %5
%25 = call i32 @sleep(i32 %24)
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* @SIGTERM
%28 = call i32 @kill(i32 1, i32 %27)
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"d:\00"
@optarg = global i32 0
@SIGTERM = global i32 0
define i32 @reboot_main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %22
5: ; preds = %2, %14
%6 = phi i32 [ %16, %14 ], [ %3, %2 ]
%7 = phi i32 [ %15, %14 ], [ 0, %2 ]
%8 = icmp eq i32 %6, 100
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* @optarg
%11 = tail call i32 @atoi(i32 %10)
br label %14
12: ; preds = %5
%13 = tail call i32 (...) @show_usage()
br label %14
14: ; preds = %12, %9
%15 = phi i32 [ %11, %9 ], [ %7, %12 ]
%16 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp sgt i32 %16, 0
br i1 %17, label %5, label %18
18: ; preds = %14
%19 = icmp sgt i32 %15, 0
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = tail call i32 @sleep(i32 %15)
br label %22
22: ; preds = %2, %20, %18
%23 = load i32, i32* @SIGTERM
%24 = tail call i32 @kill(i32 1, i32 %23)
ret i32 %24
}