#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_FAILURE;
char *basename(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
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;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *progname;
  if (argc < 1) {
    fprintf(stderr, "ERROR: This should not happen.\n");
    exit(EXIT_FAILURE);
  }
  progname = basename(argv[0]);
  if (strcmp(progname, "ip6tables") == 0)
    return ip6tables_main(argc, argv);
  if (strcmp(progname, "ip6tables-save") == 0)
    return ip6tables_save_main(argc, argv);
  if (strcmp(progname, "ip6tables-restore") == 0)
    return ip6tables_restore_main(argc, argv);
  ++argv;
  --argc;
  if (argc < 1) {
    fprintf(stderr, "ERROR: No subcommand given.\n");
    exit(EXIT_FAILURE);
  }
  progname = basename(argv[0]);
  if (strcmp(progname, "main") == 0)
    return ip6tables_main(argc, argv);
  if (strcmp(progname, "save") == 0)
    return ip6tables_save_main(argc, argv);
  if (strcmp(progname, "restore") == 0)
    return ip6tables_restore_main(argc, argv);
  fprintf(stderr,
          "ip6tables multi-purpose version: "
          "unknown subcommand \"%s\"\n",
          progname);
  exit(EXIT_FAILURE);
}


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   $0x1,-0x8(%rbp)
jge    11b5 <main+0x45>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%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    0xe50(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f3 <main+0x83>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <ip6tables_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1356 <main+0x1e6>
mov    -0x18(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1221 <main+0xb1>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <ip6tables_save_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1356 <main+0x1e6>
mov    -0x18(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    124f <main+0xdf>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <ip6tables_restore_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1356 <main+0x1e6>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1293 <main+0x123>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%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    0xdba(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12d1 <main+0x161>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <ip6tables_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1356 <main+0x1e6>
mov    -0x18(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12ff <main+0x18f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <ip6tables_save_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1356 <main+0x1e6>
mov    -0x18(%rbp),%rdi
lea    0xd39(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    132d <main+0x1bd>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <ip6tables_restore_main@plt>
mov    %eax,-0x4(%rbp)
jmp    1356 <main+0x1e6>
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1266 <main+0xf6>
mov    %rsi,%r15
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1080 <basename@plt>
mov    %rax,%rbx
lea    0xe8a(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     123e <main+0xce>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1252 <main+0xe2>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     122a <main+0xba>
cmp    $0x1,%ebp
jbe    128b <main+0x11b>
add    $0x8,%r15
add    $0xffffffff,%ebp
mov    (%r15),%rdi
call   1080 <basename@plt>
mov    %rax,%r14
lea    0xe73(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     123e <main+0xce>
lea    0xe2b(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1252 <main+0xe2>
lea    0xe26(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    129d <main+0x12d>
mov    %ebp,%edi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ip6tables_restore_main@plt>
mov    %ebp,%edi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ip6tables_main@plt>
mov    %ebp,%edi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <ip6tables_save_main@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xd8a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xdb0(%rip),%rsi
jmp    1276 <main+0x106>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    127d <main+0x10d>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"ERROR: This should not happen.\0A\00"
@EXIT_FAILURE = global i32 0
@.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 = [29 x i8] c"ERROR: No subcommand given.\0A\00"
@.str.5 = [5 x i8] c"main\00"
@.str.6 = [5 x i8] c"save\00"
@.str.7 = [8 x i8] c"restore\00"
@.str.8 = [58 x i8] c"ip6tables multi-purpose version: unknown subcommand \22%s\22\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 slt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i8* @basename(i8* %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i32, i32* %4
%24 = load i8**, i8*** %5
%25 = call i32 @ip6tables_main(i32 %23, i8** %24)
store i32 %25, i32* %3
br label %88
26: ; preds = %14
%27 = load i8*, i8** %6
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* %4
%32 = load i8**, i8*** %5
%33 = call i32 @ip6tables_save_main(i32 %31, i8** %32)
store i32 %33, i32* %3
br label %88
34: ; preds = %26
%35 = load i8*, i8** %6
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %4
%40 = load i8**, i8*** %5
%41 = call i32 @ip6tables_restore_main(i32 %39, i8** %40)
store i32 %41, i32* %3
br label %88
42: ; preds = %34
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i32 1
store i8** %44, i8*** %5
%45 = load i32, i32* %4
%46 = add nsw i32 %45, -1
store i32 %46, i32* %4
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 1
br i1 %48, label %49, label %54
49: ; preds = %42
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %42
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = call i8* @basename(i8* %57)
store i8* %58, i8** %6
%59 = load i8*, i8** %6
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %54
%63 = load i32, i32* %4
%64 = load i8**, i8*** %5
%65 = call i32 @ip6tables_main(i32 %63, i8** %64)
store i32 %65, i32* %3
br label %88
66: ; preds = %54
%67 = load i8*, i8** %6
%68 = call i64 @strcmp(i8* %67, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %66
%71 = load i32, i32* %4
%72 = load i8**, i8*** %5
%73 = call i32 @ip6tables_save_main(i32 %71, i8** %72)
store i32 %73, i32* %3
br label %88
74: ; preds = %66
%75 = load i8*, i8** %6
%76 = call i64 @strcmp(i8* %75, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %74
%79 = load i32, i32* %4
%80 = load i8**, i8*** %5
%81 = call i32 @ip6tables_restore_main(i32 %79, i8** %80)
store i32 %81, i32* %3
br label %88
82: ; preds = %74
%83 = load i32, i32* @stderr
%84 = load i8*, i8** %6
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %84)
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %78, %70, %62, %38, %30, %22
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"ERROR: This should not happen.\0A\00"
@EXIT_FAILURE = global i32 0
@.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 = [29 x i8] c"ERROR: No subcommand given.\0A\00"
@.str.5 = [5 x i8] c"main\00"
@.str.6 = [5 x i8] c"save\00"
@.str.7 = [8 x i8] c"restore\00"
@.str.8 = [58 x i8] c"ip6tables multi-purpose version: unknown subcommand \22%s\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i8* @basename(i8* %10)
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @ip6tables_main(i32 %0, i8** %1)
br label %57
16: ; preds = %9
%17 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @ip6tables_save_main(i32 %0, i8** %1)
br label %57
21: ; preds = %16
%22 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @ip6tables_restore_main(i32 %0, i8** %1)
br label %57
26: ; preds = %21
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = add nsw i32 %0, -1
%29 = icmp ult i32 %0, 2
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = tail call i32 @exit(i32 %33)
unreachable
35: ; preds = %26
%36 = load i8*, i8** %27
%37 = tail call i8* @basename(i8* %36)
%38 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = tail call i32 @ip6tables_main(i32 %28, i8** %27)
br label %57
42: ; preds = %35
%43 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = tail call i32 @ip6tables_save_main(i32 %28, i8** %27)
br label %57
47: ; preds = %42
%48 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = tail call i32 @ip6tables_restore_main(i32 %28, i8** %27)
br label %57
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i8* %37)
%55 = load i32, i32* @EXIT_FAILURE
%56 = tail call i32 @exit(i32 %55)
unreachable
57: ; preds = %50, %45, %40, %24, %19, %14
%58 = phi i32 [ %15, %14 ], [ %20, %19 ], [ %25, %24 ], [ %41, %40 ], [ %46, %45 ], [ %51, %50 ]
ret i32 %58
}