#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;
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, "iptables"))
      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,%eax
jne    11fe <main+0x7e>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <iptables_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12aa <main+0x12a>
mov    -0x18(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    122b <main+0xab>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <iptables_save_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12aa <main+0x12a>
mov    -0x18(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1258 <main+0xd8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <iptables_restore_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12aa <main+0x12a>
mov    -0x18(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1285 <main+0x105>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10a0 <iptables_xml_main@plt>
mov    %eax,-0x4(%rbp)
jmp    12aa <main+0x12a>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xda8(%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     1220 <main+0xa0>
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   %eax,%eax
je     11f6 <main+0x76>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1204 <main+0x84>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1212 <main+0x92>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1241 <main+0xc1>
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    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
lea    0xdf0(%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 = [14 x i8] c"iptables-save\00"
@.str.3 = [17 x i8] c"iptables-restore\00"
@.str.4 = [13 x i8] c"iptables-xml\00"
@.str.5 = [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 i32 @strcmp(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 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 @iptables_main(i32 %22, i8** %23)
store i32 %24, i32* %3
br label %54
25: ; preds = %13
%26 = load i8*, i8** %6
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([14 x i8], [14 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 @iptables_save_main(i32 %30, i8** %31)
store i32 %32, i32* %3
br label %54
33: ; preds = %25
%34 = load i8*, i8** %6
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([17 x i8], [17 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 @iptables_restore_main(i32 %38, i8** %39)
store i32 %40, i32* %3
br label %54
41: ; preds = %33
%42 = load i8*, i8** %6
%43 = call i32 @strcmp(i8* %42, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = load i32, i32* %4
%47 = load i8**, i8*** %5
%48 = call i32 @iptables_xml_main(i32 %46, i8** %47)
store i32 %48, i32* %3
br label %54
49: ; preds = %41
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %6
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %51)
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %45, %37, %29, %21
%55 = load i32, i32* %3
ret i32 %55
}

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