#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__ ENOENT;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ dofile();
int dup2(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int getopt(int, char **, char *);
scalar_t__ isatty(int /*<<< orphan*/);
scalar_t__ optind;
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strerror(scalar_t__);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int exit_status;
  while (getopt(argc, argv, "") != -1) {
    usage();
  }
  argc -= optind;
  argv += optind;
  if (argc < 1)
    usage();
  if (isatty(STDOUT_FILENO))
    dofile();
  if (isatty(STDERR_FILENO) && dup2(STDOUT_FILENO, STDERR_FILENO) == -1) {
    (void)fprintf(stdin, "nohup: %s\n", strerror(errno));
    exit(127);
  }
  (void)signal(SIGHUP, SIG_IGN);
  execvp(argv[0], &argv[0]);
  exit_status = (errno == ENOENT) ? 127 : 126;
  (void)fprintf(stderr, "nohup: %s: %s\n", argv[0], strerror(errno));
  exit(exit_status);
}


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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe46(%rip),%rdx
call   1090 <getopt@plt>
cmp    $0xffffffff,%eax
je     11de <main+0x3e>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    11b6 <main+0x16>
mov    0x2deb(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dd7(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1219 <main+0x79>
mov    $0x0,%al
call   1080 <usage@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1040 <isatty@plt>
cmp    $0x0,%rax
je     1238 <main+0x98>
mov    $0x0,%al
call   1030 <dofile@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
call   1040 <isatty@plt>
cmp    $0x0,%rax
je     12a9 <main+0x109>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    12a9 <main+0x109>
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d2d(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x7f,%edi
call   10b0 <exit@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
mov    0x2d0f(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <execvp@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%rdx
mov    0x2cb7(%rip),%rax
mov    (%rax),%rsi
mov    $0x7e,%eax
mov    $0x7f,%ecx
cmp    %rsi,%rdx
cmove  %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    0x2cba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c9b(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xcdd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe57(%rip),%rdx
call   1090 <getopt@plt>
cmp    $0xffffffff,%eax
je     11e9 <main+0x49>
lea    0xe46(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <usage@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1090 <getopt@plt>
cmp    $0xffffffff,%eax
jne    11d0 <main+0x30>
mov    0x2de0(%rip),%rax
mov    (%rax),%rbx
sub    %ebx,%ebp
test   %ebp,%ebp
jg     1200 <main+0x60>
xor    %eax,%eax
call   1080 <usage@plt>
mov    0x2de1(%rip),%r15
mov    (%r15),%edi
call   1040 <isatty@plt>
test   %rax,%rax
je     121b <main+0x7b>
xor    %eax,%eax
call   1030 <dofile@plt>
mov    0x2d86(%rip),%rbp
mov    0x0(%rbp),%edi
call   1040 <isatty@plt>
test   %rax,%rax
je     1274 <main+0xd4>
mov    (%r15),%edi
mov    0x0(%rbp),%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1274 <main+0xd4>
mov    0x2d92(%rip),%rax
mov    (%rax),%ebx
mov    0x2d61(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
lea    0xda2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x7f,%edi
call   10b0 <exit@plt>
lea    (%r14,%rbx,8),%rbx
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
mov    (%rbx),%rdi
mov    %rbx,%rsi
call   10a0 <execvp@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%rdi
mov    0x2ced(%rip),%rax
xor    %ebp,%ebp
cmp    (%rax),%rdi
sete   %bpl
or     $0x7e,%ebp
mov    0x2cfa(%rip),%rax
mov    (%rax),%r14d
mov    (%rbx),%rbx
call   10c0 <strerror@plt>
lea    0xd3b(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebp,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@optind = global i64 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@stdin = global i32 0
@.str.1 = [11 x i8] c"nohup: %s\0A\00"
@errno = global i64 0
@SIGHUP = global i32 0
@SIG_IGN = global i32 0
@ENOENT = global i64 0
@stderr = global i32 0
@.str.2 = [15 x i8] c"nohup: %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %12, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 (...) @usage()
br label %7
14: ; preds = %7
%15 = load i64, i64* @optind
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = sub nsw i64 %17, %15
%19 = trunc i64 %18 to i32
store i32 %19, i32* %4
%20 = load i64, i64* @optind
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 %20
store i8** %22, i8*** %5
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %14
%26 = call i32 (...) @usage()
br label %27
27: ; preds = %25, %14
%28 = load i32, i32* @STDOUT_FILENO
%29 = call i64 @isatty(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (...) @dofile()
br label %33
33: ; preds = %31, %27
%34 = load i32, i32* @STDERR_FILENO
%35 = call i64 @isatty(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %48
37: ; preds = %33
%38 = load i32, i32* @STDOUT_FILENO
%39 = load i32, i32* @STDERR_FILENO
%40 = call i32 @dup2(i32 %38, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %48
42: ; preds = %37
%43 = load i32, i32* @stdin
%44 = load i64, i64* @errno
%45 = call i8* @strerror(i64 %44)
%46 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %45)
%47 = call i32 @exit(i32 127)
unreachable
48: ; preds = %37, %33
%49 = load i32, i32* @SIGHUP
%50 = load i32, i32* @SIG_IGN
%51 = call i32 @signal(i32 %49, i32 %50)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = call i32 @execvp(i8* %54, i8** %56)
%58 = load i64, i64* @errno
%59 = load i64, i64* @ENOENT
%60 = icmp eq i64 %58, %59
%61 = zext i1 %60 to i64
%62 = select i1 %60, i32 127, i32 126
store i32 %62, i32* %6
%63 = load i32, i32* @stderr
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 0
%66 = load i8*, i8** %65
%67 = load i64, i64* @errno
%68 = call i8* @strerror(i64 %67)
%69 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %66, i8* %68)
%70 = load i32, i32* %6
%71 = call i32 @exit(i32 %70)
unreachable
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@optind = global i64 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@stdin = global i32 0
@.str.1 = [11 x i8] c"nohup: %s\0A\00"
@errno = global i64 0
@SIGHUP = global i32 0
@SIG_IGN = global i32 0
@ENOENT = global i64 0
@stderr = global i32 0
@.str.2 = [15 x i8] c"nohup: %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %9, label %5
5: ; preds = %2, %5
%6 = tail call i32 (...) @usage()
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %5
9: ; preds = %5, %2
%10 = load i64, i64* @optind
%11 = trunc i64 %10 to i32
%12 = sub i32 %0, %11
%13 = getelementptr inbounds i8*, i8** %1, i64 %10
%14 = icmp slt i32 %12, 1
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 (...) @usage()
br label %17
17: ; preds = %15, %9
%18 = load i32, i32* @STDOUT_FILENO
%19 = tail call i64 @isatty(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i32 (...) @dofile()
br label %23
23: ; preds = %21, %17
%24 = load i32, i32* @STDERR_FILENO
%25 = tail call i64 @isatty(i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %38, label %27
27: ; preds = %23
%28 = load i32, i32* @STDOUT_FILENO
%29 = load i32, i32* @STDERR_FILENO
%30 = tail call i32 @dup2(i32 %28, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = load i32, i32* @stdin
%34 = load i64, i64* @errno
%35 = tail call i8* @strerror(i64 %34)
%36 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = tail call i32 @exit(i32 127)
unreachable
38: ; preds = %27, %23
%39 = load i32, i32* @SIGHUP
%40 = load i32, i32* @SIG_IGN
%41 = tail call i32 @signal(i32 %39, i32 %40)
%42 = load i8*, i8** %13
%43 = tail call i32 @execvp(i8* %42, i8** %13)
%44 = load i64, i64* @errno
%45 = load i64, i64* @ENOENT
%46 = icmp eq i64 %44, %45
%47 = select i1 %46, i32 127, i32 126
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %13
%50 = tail call i8* @strerror(i64 %44)
%51 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %49, i8* %50)
%52 = tail call i32 @exit(i32 %47)
unreachable
}