#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 get_address_family(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int af = get_address_family(argv[1]);
  switch (af) {
  case 3:
    printf("Supports IPv4\n");
    break;
  case 4:
    printf("Supports IPv6\n");
    break;
  default:
    printf("No valid result\n");
  }
  return 0;
}


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    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <get_address_family@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x3,%eax
je     116b <main+0x4b>
jmp    115a <main+0x3a>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
je     117c <main+0x5c>
jmp    118d <main+0x6d>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    1199 <main+0x79>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    1199 <main+0x79>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rdi
call   1040 <get_address_family@plt>
cmp    $0x4,%eax
lea    0xecc(%rip),%rcx
lea    0xee1(%rip),%rdx
cmove  %rcx,%rdx
cmp    $0x3,%eax
lea    0xec5(%rip),%rdi
cmovne %rdx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Supports IPv4\0A\00"
@.str.1 = [15 x i8] c"Supports IPv6\0A\00"
@.str.2 = [17 x i8] c"No valid result\0A\00"
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
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @get_address_family(i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
switch i32 %11, label %16 [
i32 3, label %12
i32 4, label %14
]
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %18
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %14, %12
ret i32 0
}

LLVM IR (-O2):
@str = [14 x i8] c"Supports IPv6\00"
@str.3 = [14 x i8] c"Supports IPv4\00"
@str.4 = [16 x i8] c"No valid result\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @get_address_family(i8* %4)
%6 = icmp eq i32 %5, 4
%7 = select i1 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0)
%8 = icmp eq i32 %5, 3
%9 = select i1 %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0), i8* %7
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 0
}