#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 *basename(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ip6tables_main(int, char **);
int ip6tables_restore_main(int, char **);
int ip6tables_save_main(int, char **);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *progname;
  if (argc == 0) {
    fprintf(stderr, "no argv[0]?");
    exit(1);
  } else {
    progname = basename(argv[0]);
    if (!strcmp(progname, "ip6tables"))
      return ip6tables_main(argc, argv);
    if (!strcmp(progname, "ip6tables-save"))
      return ip6tables_save_main(argc, argv);
    if (!strcmp(progname, "ip6tables-restore"))
      return ip6tables_restore_main(argc, argv);
    fprintf(stderr, "ip6tables multi-purpose version: unknown applet name %s\n",
            progname);
    exit(1);
  }
}


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)
cmpl   $0x0,-0x8(%rbp)
jne    11b1 <main+0x41>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <basename@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ee <main+0x7e>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <ip6tables_main@plt>
mov    %eax,-0x4(%rbp)
jmp    126d <main+0xfd>
mov    -0x18(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    121b <main+0xab>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <ip6tables_save_main@plt>
mov    %eax,-0x4(%rbp)
jmp    126d <main+0xfd>
mov    -0x18(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1248 <main+0xd8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <ip6tables_restore_main@plt>
mov    %eax,-0x4(%rbp)
jmp    126d <main+0xfd>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
je     11eb <main+0x7b>
mov    %rsi,%r14
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1080 <basename@plt>
mov    %rax,%rbx
lea    0xe7d(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11cf <main+0x5f>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11dd <main+0x6d>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    120c <main+0x9c>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ip6tables_restore_main@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <ip6tables_main@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <ip6tables_save_main@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"no argv[0]?\00"
@.str.1 = [10 x i8] c"ip6tables\00"
@.str.2 = [15 x i8] c"ip6tables-save\00"
@.str.3 = [18 x i8] c"ip6tables-restore\00"
@.str.4 = [57 x i8] c"ip6tables multi-purpose version: unknown applet name %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i8* @basename(i8* %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %13
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @ip6tables_main(i32 %22, i8** %23)
store i32 %24, i32* %3
br label %46
25: ; preds = %13
%26 = load i8*, i8** %6
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32, i32* %4
%31 = load i8**, i8*** %5
%32 = call i32 @ip6tables_save_main(i32 %30, i8** %31)
store i32 %32, i32* %3
br label %46
33: ; preds = %25
%34 = load i8*, i8** %6
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %33
%38 = load i32, i32* %4
%39 = load i8**, i8*** %5
%40 = call i32 @ip6tables_restore_main(i32 %38, i8** %39)
store i32 %40, i32* %3
br label %46
41: ; preds = %33
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %6
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %37, %29, %21
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"no argv[0]?\00"
@.str.1 = [10 x i8] c"ip6tables\00"
@.str.2 = [15 x i8] c"ip6tables-save\00"
@.str.3 = [18 x i8] c"ip6tables-restore\00"
@.str.4 = [57 x i8] c"ip6tables multi-purpose version: unknown applet name %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i8* @basename(i8* %9)
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @ip6tables_main(i32 %0, i8** %1)
br label %29
15: ; preds = %8
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @ip6tables_save_main(i32 %0, i8** %1)
br label %29
20: ; preds = %15
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @ip6tables_restore_main(i32 %0, i8** %1)
br label %29
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %23, %18, %13
%30 = phi i32 [ %24, %23 ], [ %19, %18 ], [ %14, %13 ]
ret i32 %30
}