#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*/ ftp_close(int);
int ftp_open(char *, char *, char *);
int /*<<< orphan*/ ftp_send(int, char *, char *, int /*<<< orphan*/);
char *http(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int main() {
  char *ip = http("automation.whatismyip.com", "/n09230945.asp");
  printf("Your IP is %s\n\n", ip);
  printf("Now doing ftp.\n");
  char *host = "localhost";
  char *user = "root";
  char *pass = "";
  int ftp = ftp_open(host, user, pass);
  ftp_send(ftp, "ip.txt", ip, strlen(ip));
  ftp_close(ftp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe91(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1060 <http@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xea3(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe7c(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <ftp_open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
lea    0xe5d(%rip),%rsi
call   1080 <ftp_send@plt>
mov    -0x24(%rbp),%edi
call   1030 <ftp_close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe86(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1070 <http@plt>
mov    %rax,%rbx
lea    0xe99(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%rdi
lea    0xe8f(%rip),%rsi
lea    0xe7d(%rip),%rdx
call   1050 <ftp_open@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0xe77(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1090 <ftp_send@plt>
mov    %ebp,%edi
call   1030 <ftp_close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"automation.whatismyip.com\00"
@.str.1 = [15 x i8] c"/n09230945.asp\00"
@.str.2 = [16 x i8] c"Your IP is %s\0A\0A\00"
@.str.3 = [16 x i8] c"Now doing ftp.\0A\00"
@.str.4 = [10 x i8] c"localhost\00"
@.str.5 = [5 x i8] c"root\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [7 x i8] c"ip.txt\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = call i8* @http(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i8* %6, i8** %1
%7 = load i8*, i8** %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8** %4
%10 = load i8*, i8** %2
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = call i32 @ftp_open(i8* %10, i8* %11, i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = load i8*, i8** %1
%16 = load i8*, i8** %1
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @ftp_send(i32 %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %15, i32 %17)
%19 = load i32, i32* %5
%20 = call i32 @ftp_close(i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"automation.whatismyip.com\00"
@.str.1 = [15 x i8] c"/n09230945.asp\00"
@.str.2 = [16 x i8] c"Your IP is %s\0A\0A\00"
@.str.4 = [10 x i8] c"localhost\00"
@.str.5 = [5 x i8] c"root\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [7 x i8] c"ip.txt\00"
@str = [15 x i8] c"Now doing ftp.\00"
define i32 @main() {
%1 = tail call i8* @http(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @ftp_open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i32 @ftp_send(i32 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %1, i32 %5)
%7 = tail call i32 @ftp_close(i32 %4)
ret i32 0
}