#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 Is_Valid_IP(char const *);
int /*<<< orphan*/ My_HTTP_GET(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void Locate_This_IP(const char *tIP) {
  if (Is_Valid_IP(tIP) != 1) {
    printf("Not a valid IP address\n");
  } else {
    char message_city[64] = {0};
    strcpy(message_city, "GET /");
    strcat(message_city, tIP);
    char message_country[64] = {0};
    strcpy(message_country, message_city);
    strcat(message_city, "/city");
    strcat(message_city, " HTTP/1.1\r\nHost:ipinfo.io\r\n\r\n");
    int message_length = strlen(message_city);
    My_HTTP_GET(message_city, message_length);
    strcat(message_country, "/country");
    strcat(message_country, " HTTP/1.1\r\nHost:ipinfo.io\r\n\r\n");
    message_length = strlen(message_country);
    My_HTTP_GET(message_country, message_length);
  }
}


x86 assembly (clang, -O0):
<Locate_This_IP>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <Is_Valid_IP@plt>
cmp    $0x1,%eax
je     11a2 <Locate_This_IP+0x32>
lea    0xe68(%rip),%rdi
call   1060 <printf@plt>
jmp    127a <Locate_This_IP+0x10a>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    -0x50(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x50(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x94(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x94(%rbp),%esi
call   1080 <My_HTTP_GET@plt>
lea    -0x90(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x90(%rbp),%rdi
lea    0xdd3(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%esi
call   1080 <My_HTTP_GET@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Locate_This_IP>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
call   1050 <Is_Valid_IP@plt>
cmp    $0x1,%eax
jne    1243 <Locate_This_IP+0xe3>
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
lea    0xe65(%rip),%rsi
lea    0x40(%rsp),%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe28(%rip),%rsi
mov    %r15,%rdi
call   1080 <strcat@plt>
lea    0xe1f(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1070 <My_HTTP_GET@plt>
lea    0xe19(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1070 <My_HTTP_GET@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xde9(%rip),%rdi
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Not a valid IP address\0A\00"
@.str.1 = [6 x i8] c"GET /\00"
@.str.2 = [6 x i8] c"/city\00"
@.str.3 = [30 x i8] c" HTTP/1.1\0D\0AHost:ipinfo.io\0D\0A\0D\0A\00"
@.str.4 = [9 x i8] c"/country\00"
define void @Locate_This_IP(i8* %0) {
%2 = alloca i8*
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @Is_Valid_IP(i8* %6)
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %40
11: ; preds = %1
%12 = bitcast [64 x i8]* %3 to i8*
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%16 = load i8*, i8** %2
%17 = call i32 @strcat(i8* %15, i8* %16)
%18 = bitcast [64 x i8]* %4 to i8*
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
store i32 %27, i32* %5
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%29 = load i32, i32* %5
%30 = call i32 @My_HTTP_GET(i8* %28, i32 %29)
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
store i32 %36, i32* %5
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%38 = load i32, i32* %5
%39 = call i32 @My_HTTP_GET(i8* %37, i32 %38)
br label %40
40: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"GET /\00"
@.str.2 = [6 x i8] c"/city\00"
@.str.3 = [30 x i8] c" HTTP/1.1\0D\0AHost:ipinfo.io\0D\0A\0D\0A\00"
@.str.4 = [9 x i8] c"/country\00"
@str = [23 x i8] c"Not a valid IP address\00"
define void @Locate_This_IP(i8* %0) {
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
%4 = tail call i32 @Is_Valid_IP(i8* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %22
8: ; preds = %1
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @strcat(i8* %9, i8* %0)
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i8* %9)
%14 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @strlen(i8* %9)
%17 = call i32 @My_HTTP_GET(i8* %9, i32 %16)
%18 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @strlen(i8* %12)
%21 = call i32 @My_HTTP_GET(i8* %12, i32 %20)
br label %22
22: ; preds = %8, %6
ret void
}