#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 */
struct in_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *inet_ntoa(struct in_addr);
scalar_t__ interface_ip(char *, struct in_addr *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct in_addr ip;
  if (argc < 2) {
    fprintf(stderr, "Get IP address for a network interface.\n");
    fprintf(stderr, "Usage: %s eth0|wlan0|...\n", argv[0]);
    exit(1);
  }
  if (interface_ip(argv[1], &ip) == 0) {
    printf("%s\tinet addr:%s\n", argv[1], inet_ntoa(ip));
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    11af <main+0x5f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <interface_ip@plt>
cmp    $0x0,%rax
jne    11f1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    1195 <main+0x45>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1030 <interface_ip@plt>
test   %rax,%rax
jne    118b <main+0x3b>
mov    0x8(%rbx),%rbx
mov    (%rsp),%edi
call   1040 <inet_ntoa@plt>
lea    0xec3(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e44(%rip),%r14
mov    (%r14),%edi
lea    0xe5a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@stderr = global i32 0
@.str = [41 x i8] c"Get IP address for a network interface.\0A\00"
@.str.1 = [26 x i8] c"Usage: %s eth0|wlan0|...\0A\00"
@.str.2 = [17 x i8] c"%s\09inet addr:%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.in_addr
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, 2
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @interface_ip(i8* %21, %struct.in_addr* %6)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i8* @inet_ntoa(i32 %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %30)
br label %32
32: ; preds = %24, %18
ret i32 0
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@stderr = global i32 0
@.str = [41 x i8] c"Get IP address for a network interface.\0A\00"
@.str.1 = [26 x i8] c"Usage: %s eth0|wlan0|...\0A\00"
@.str.2 = [17 x i8] c"%s\09inet addr:%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.in_addr
%4 = bitcast %struct.in_addr* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @interface_ip(i8* %15, %struct.in_addr* %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i8*, i8** %14
%20 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
%21 = load i32, i32* %20
%22 = call i8* @inet_ntoa(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %22)
br label %24
24: ; preds = %18, %13
ret i32 0
}