#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ emit_help();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ symlink(char *, char *);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  int ch;
  while ((ch = getopt(argc, argv, "h?s")) != -1) {
    switch (ch) {
    case 's':
      break;
    case 'h':
    case '?':
    default:
      emit_help();
    }
  }
  argc -= optind;
  argv += optind;
  while (1) {
    symlink(argv[0], argv[1]);
    unlink(argv[1]);
  }
  exit(EXIT_SUCCESS);
}


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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9c(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11c1 <main+0x81>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x3f,%eax
je     11b0 <main+0x70>
jmp    1189 <main+0x49>
mov    -0x18(%rbp),%eax
sub    $0x68,%eax
je     11b0 <main+0x70>
jmp    119a <main+0x5a>
mov    -0x18(%rbp),%eax
sub    $0x73,%eax
jne    11b5 <main+0x75>
jmp    11ab <main+0x6b>
jmp    11bc <main+0x7c>
jmp    11b5 <main+0x75>
mov    $0x0,%al
call   1040 <emit_help@plt>
jmp    1156 <main+0x16>
mov    0x2e20(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2e0c(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1050 <symlink@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <unlink@plt>
jmp    11eb <main+0xab>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeb0(%rip),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
cmp    $0x73,%eax
je     1150 <main+0x10>
cmp    $0xffffffff,%eax
je     1170 <main+0x30>
xor    %eax,%eax
call   1040 <emit_help@plt>
jmp    1150 <main+0x10>
mov    0x2e71(%rip),%rax
mov    (%rax),%rbp
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rdi
mov    0x8(%rbx,%rbp,8),%rsi
call   1050 <symlink@plt>
mov    0x8(%rbx,%rbp,8),%rdi
call   1030 <unlink@plt>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [4 x i8] c"h?s\00"
@optind = global i64 0
@EXIT_SUCCESS = global i32 0
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 = %18, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %16 [
i32 115, label %14
i32 104, label %15
i32 63, label %15
]
14: ; preds = %12
br label %18
15: ; preds = %12, %12
br label %16
16: ; preds = %12, %15
%17 = call i32 (...) @emit_help()
br label %18
18: ; preds = %16, %14
br label %7
19: ; preds = %7
%20 = load i64, i64* @optind
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = sub nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %4
%25 = load i64, i64* @optind
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 %25
store i8** %27, i8*** %5
br label %28
28: ; preds = %19, %28
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @symlink(i8* %31, i8* %34)
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @unlink(i8* %38)
br label %28
}

LLVM IR (-O2):
@.str = [4 x i8] c"h?s\00"
@optind = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %6 [
i32 -1, label %8
i32 115, label %5
]
5: ; preds = %3, %6
br label %3
6: ; preds = %3
%7 = tail call i32 (...) @emit_help()
br label %5
8: ; preds = %3
%9 = load i64, i64* @optind
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = getelementptr inbounds i8*, i8** %10, i64 1
br label %12
12: ; preds = %12, %8
%13 = load i8*, i8** %10
%14 = load i8*, i8** %11
%15 = tail call i32 @symlink(i8* %13, i8* %14)
%16 = load i8*, i8** %11
%17 = tail call i32 @unlink(i8* %16)
br label %12
}