#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;
int EXIT_SUCCESS;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_gatewayip(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char gateway[INET_ADDRSTRLEN];
  if (get_gatewayip(gateway, INET_ADDRSTRLEN) == -1) {
    fprintf(stderr, "exiting application ...\n");
    exit(EXIT_FAILURE);
  }
  printf("Default Gateaway : %s\n", gateway);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
call   1050 <get_gatewayip@plt>
cmp    $0xffffffff,%eax
jne    11bc <main+0x7c>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1050 <get_gatewayip@plt>
cmp    $0xffffffff,%eax
je     118f <main+0x4f>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@INET_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"exiting application ...\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [23 x i8] c"Default Gateaway : %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @INET_ADDRSTRLEN
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %6
%11 = alloca i8, i64 %9
store i64 %9, i64* %7
%12 = load i32, i32* @INET_ADDRSTRLEN
%13 = call i32 @get_gatewayip(i8* %11, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%22 = load i32, i32* @EXIT_SUCCESS
store i32 %22, i32* %3
%23 = load i8*, i8** %6
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@INET_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"exiting application ...\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [23 x i8] c"Default Gateaway : %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @INET_ADDRSTRLEN
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @get_gatewayip(i8* %5, i32 %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}