#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 */
typedef int /*<<< orphan*/ addrstr;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
char *lookup_host(char *, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char *argv[]) {
  char addrstr[100];
  printf("%s starting.  Built on %s at %s\n",
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/LossyHorizon/BeagleBoneCodeSamples/refs/"
         "heads/master/06-lookUpUsing_getaddrinfo.c",
         "Mar 16 2022", "22:21:09");
  if (argc < 2) {
    printf("%03d: ERROR: you must give an address to lookup \n", 76);
    exit(1);
  }
  if (strlen(argv[1]) < 3) {
    printf("%03d: ERROR: you must give an address to lookup \n", 81);
    exit(1);
  }
  printf("%03d: Found IP address: (%s) \n", 85,
         lookup_host(addrstr, sizeof(addrstr) - 1, argv[1]));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
lea    0xeba(%rip),%rsi
lea    0xf5f(%rip),%rdx
lea    0xf64(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11a3 <main+0x63>
lea    0xf55(%rip),%rdi
mov    $0x4c,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jge    11d6 <main+0x96>
lea    0xf22(%rip),%rdi
mov    $0x51,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    $0x63,%esi
call   1050 <lookup_host@plt>
mov    %rax,%rdx
lea    0xf1e(%rip),%rdi
mov    $0x55,%esi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeae(%rip),%rdi
lea    0xec8(%rip),%rsi
lea    0xf6d(%rip),%rdx
lea    0xf72(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebp
jle    11b1 <main+0x71>
mov    0x8(%rbx),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    11bf <main+0x7f>
mov    0x8(%rbx),%rdx
mov    %rsp,%rdi
mov    $0x63,%esi
call   1050 <lookup_host@plt>
lea    0xf7b(%rip),%rdi
mov    $0x55,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xf2a(%rip),%rdi
mov    $0x4c,%esi
jmp    11cb <main+0x8b>
lea    0xf1c(%rip),%rdi
mov    $0x51,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"%s starting. Built on %s at %s\0A\00"
@.str.1 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/LossyHorizon/BeagleBoneCodeSamples/refs/heads/master/06-lookUpUsing_getaddrinfo.c\00"
@.str.2 = [12 x i8] c"Mar 16 2022\00"
@.str.3 = [9 x i8] c"22:21:09\00"
@.str.4 = [50 x i8] c"%03d: ERROR: you must give an address to lookup \0A\00"
@.str.5 = [31 x i8] c"%03d: Found IP address: (%s) \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 76)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 81)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %13
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i8* @lookup_host(i8* %23, i32 99, i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 85, i8* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"%s starting. Built on %s at %s\0A\00"
@.str.1 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/LossyHorizon/BeagleBoneCodeSamples/refs/heads/master/06-lookUpUsing_getaddrinfo.c\00"
@.str.2 = [12 x i8] c"Mar 16 2022\00"
@.str.3 = [9 x i8] c"22:21:09\00"
@.str.4 = [50 x i8] c"%03d: ERROR: you must give an address to lookup \0A\00"
@.str.5 = [31 x i8] c"%03d: Found IP address: (%s) \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 76)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %12)
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 81)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %10
%19 = load i8*, i8** %11
%20 = call i8* @lookup_host(i8* %4, i32 99, i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 85, i8* %20)
ret i32 0
}