#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(int);
int /*<<< orphan*/ get_ip(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Please provide a hostname");
    exit(1);
  }
  char *hostname = argv[1];
  char ip[100];
  get_ip(hostname, ip);
  printf("%s resolved to %s", hostname, ip);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1164 <main+0x34>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1040 <get_ip@plt>
mov    -0x18(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
cmp    $0x1,%edi
jle    1186 <main+0x46>
mov    0x8(%rsi),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <get_ip@plt>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Please provide a hostname\00"
@.str.1 = [18 x i8] c"%s resolved to %s\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca [100 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = call i32 @get_ip(i8* %16, i8* %17)
%19 = load i8*, i8** %5
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Please provide a hostname\00"
@.str.1 = [18 x i8] c"%s resolved to %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = call i32 @get_ip(i8* %10, i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11)
%14 = call i32 @putchar(i32 10)
ret i32 0
}