#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 iptables_main(int, char **);
int iptables_restore_main(int, char **);
int iptables_save_main(int, char **);
int iptables_xml_main(int, char **);
int /*<<< orphan*/ stderr;
scalar_t__ 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, "iptables") ||
        strcmp(progname, "iptables-static") == 0)
      return iptables_main(argc, argv);
    if (!strcmp(progname, "iptables-save"))
      return iptables_save_main(argc, argv);
    if (!strcmp(progname, "iptables-restore"))
      return iptables_restore_main(argc, argv);
    if (!strcmp(progname, "iptables-xml"))
      return iptables_xml_main(argc, argv);
    fprintf(stderr, "iptables 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    11c1 <main+0x41>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1205 <main+0x85>
mov    -0x18(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1219 <main+0x99>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <iptables_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12c8 <main+0x148>
mov    -0x18(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1247 <main+0xc7>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <iptables_save_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12c8 <main+0x148>
mov    -0x18(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1275 <main+0xf5>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <iptables_restore_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12c8 <main+0x148>
mov    -0x18(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a3 <main+0x123>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10a0 <iptables_xml_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12c8 <main+0x148>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <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     1238 <main+0xb8>
mov    %rsi,%r14
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1060 <basename@plt>
mov    %rax,%rbx
lea    0xe69(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120e <main+0x8e>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120e <main+0x8e>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     121c <main+0x9c>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     122a <main+0xaa>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1259 <main+0xd9>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10a0 <iptables_xml_main@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <iptables_main@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <iptables_save_main@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <iptables_restore_main@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"no argv[0]?\00"
@.str.1 = [9 x i8] c"iptables\00"
@.str.2 = [16 x i8] c"iptables-static\00"
@.str.3 = [14 x i8] c"iptables-save\00"
@.str.4 = [17 x i8] c"iptables-restore\00"
@.str.5 = [13 x i8] c"iptables-xml\00"
@.str.6 = [56 x i8] c"iptables 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 i64 @strcmp(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = load i8*, i8** %6
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21, %13
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i32 @iptables_main(i32 %26, i8** %27)
store i32 %28, i32* %3
br label %58
29: ; preds = %21
%30 = load i8*, i8** %6
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i32, i32* %4
%35 = load i8**, i8*** %5
%36 = call i32 @iptables_save_main(i32 %34, i8** %35)
store i32 %36, i32* %3
br label %58
37: ; preds = %29
%38 = load i8*, i8** %6
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp ne i64 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = load i32, i32* %4
%43 = load i8**, i8*** %5
%44 = call i32 @iptables_restore_main(i32 %42, i8** %43)
store i32 %44, i32* %3
br label %58
45: ; preds = %37
%46 = load i8*, i8** %6
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i32, i32* %4
%51 = load i8**, i8*** %5
%52 = call i32 @iptables_xml_main(i32 %50, i8** %51)
store i32 %52, i32* %3
br label %58
53: ; preds = %45
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %6
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49, %41, %33, %25
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"no argv[0]?\00"
@.str.1 = [9 x i8] c"iptables\00"
@.str.2 = [16 x i8] c"iptables-static\00"
@.str.3 = [14 x i8] c"iptables-save\00"
@.str.4 = [17 x i8] c"iptables-restore\00"
@.str.5 = [13 x i8] c"iptables-xml\00"
@.str.6 = [56 x i8] c"iptables 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 i64 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13, %8
%17 = tail call i32 @iptables_main(i32 %0, i8** %1)
br label %37
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @iptables_save_main(i32 %0, i8** %1)
br label %37
23: ; preds = %18
%24 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @iptables_restore_main(i32 %0, i8** %1)
br label %37
28: ; preds = %23
%29 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 @iptables_xml_main(i32 %0, i8** %1)
br label %37
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %31, %26, %21, %16
%38 = phi i32 [ %17, %16 ], [ %32, %31 ], [ %27, %26 ], [ %22, %21 ]
ret i32 %38
}