#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*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
char *strstr(char *, char *);
int main(void) {
  char tmp_url[1024] = {0};
  char ip[1024] = {0};
  char *p1 = NULL;
  strcat(tmp_url, "CurrentMyIPAddress:115.94.72.52.");
  p1 = strstr(tmp_url, "CurrentMyIPAddress:");
  if (p1 != NULL) {
    p1 += strlen("CurrentMyIPAddress:");
    strncpy(ip, p1, strlen(p1) - 1);
    printf("detected IP: %s\n", ip);
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movq   $0x0,-0x818(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     1259 <main+0xf9>
lea    0xe3c(%rip),%rdi
call   1040 <strlen@plt>
add    -0x818(%rbp),%rax
mov    %rax,-0x818(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x818(%rbp),%rax
mov    %rax,-0x820(%rbp)
mov    -0x818(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x828(%rbp),%rdi
mov    -0x820(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1030 <strncpy@plt>
lea    -0x810(%rbp),%rsi
lea    0xded(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1260 <main+0x100>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
lea    0x400(%rsp),%rbx
xor    %ebp,%ebp
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     11e8 <main+0x88>
mov    %rax,%rbx
add    $0x13,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
lea    0xe57(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
jmp    11ed <main+0x8d>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"CurrentMyIPAddress:115.94.72.52.\00"
@.str.1 = [20 x i8] c"CurrentMyIPAddress:\00"
@.str.2 = [17 x i8] c"detected IP: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [1024 x i8]* %2 to i8*
%6 = bitcast [1024 x i8]* %3 to i8*
store i8* null, i8** %4
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %25
13: ; preds = %0
%14 = call i64 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 %14
store i8* %16, i8** %4
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = call i64 @strlen(i8* %19)
%21 = sub nsw i64 %20, 1
%22 = call i32 @strncpy(i8* %17, i8* %18, i64 %21)
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %23)
store i32 0, i32* %1
br label %26
25: ; preds = %0
store i32 -1, i32* %1
br label %26
26: ; preds = %25, %13
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [33 x i8] c"CurrentMyIPAddress:115.94.72.52.\00"
@.str.1 = [20 x i8] c"CurrentMyIPAddress:\00"
@.str.2 = [17 x i8] c"detected IP: %s\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %14, label %8
8: ; preds = %0
%9 = getelementptr inbounds i8, i8* %6, i64 19
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %10, -1
%12 = call i32 @strncpy(i8* %4, i8* %9, i64 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %14
14: ; preds = %0, %8
%15 = phi i32 [ 0, %8 ], [ -1, %0 ]
ret i32 %15
}