#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int system(char *);
void Locate_My_IP() {
  printf("Your IP address is:");
  printf("\n");
  int result = system("curl ipinfo.io/ip");
  if (result == -1 || result == 127) {
    printf("Error: IP could not be resolved\n");
    exit(EXIT_FAILURE);
  }
  printf("from city of:");
  printf("\n");
  result = system("curl ipinfo.io/city");
  if (result == -1 || result == 127) {
    printf("Error: Location could not be resolved\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<Locate_My_IP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xefa(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     1173 <Locate_My_IP+0x43>
cmpl   $0x7f,-0x4(%rbp)
jne    118d <Locate_My_IP+0x5d>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     11c8 <Locate_My_IP+0x98>
cmpl   $0x7f,-0x4(%rbp)
jne    11e2 <Locate_My_IP+0xb2>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Locate_My_IP>:
push   %rax
lea    0xea8(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xea6(%rip),%rdi
call   1050 <system@plt>
cmp    $0x7f,%eax
je     11ab <Locate_My_IP+0x5b>
cmp    $0xffffffff,%eax
je     11ab <Locate_My_IP+0x5b>
lea    0xea2(%rip),%rdi
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe9a(%rip),%rdi
call   1050 <system@plt>
cmp    $0x7f,%eax
je     11b4 <Locate_My_IP+0x64>
cmp    $0xffffffff,%eax
je     11b4 <Locate_My_IP+0x64>
pop    %rax
ret
lea    0xebc(%rip),%rdi
jmp    11bb <Locate_My_IP+0x6b>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Your IP address is:\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [18 x i8] c"curl ipinfo.io/ip\00"
@.str.3 = [33 x i8] c"Error: IP could not be resolved\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [14 x i8] c"from city of:\00"
@.str.5 = [20 x i8] c"curl ipinfo.io/city\00"
@.str.6 = [39 x i8] c"Error: Location could not be resolved\0A\00"
define void @Locate_My_IP() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, -1
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 127
br i1 %9, label %10, label %14
10: ; preds = %7, %0
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
store i32 %17, i32* %1
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, -1
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 127
br i1 %22, label %23, label %27
23: ; preds = %20, %14
%24 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Your IP address is:\00"
@.str.2 = [18 x i8] c"curl ipinfo.io/ip\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [14 x i8] c"from city of:\00"
@.str.5 = [20 x i8] c"curl ipinfo.io/city\00"
@str = [38 x i8] c"Error: Location could not be resolved\00"
@str.7 = [32 x i8] c"Error: IP could not be resolved\00"
define void @Locate_My_IP() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @putchar(i32 10)
%3 = tail call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
switch i32 %3, label %8 [
i32 -1, label %4
i32 127, label %4
]
4: ; preds = %0, %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %0
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
switch i32 %11, label %16 [
i32 -1, label %12
i32 127, label %12
]
12: ; preds = %8, %8
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %8
ret void
}