#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*/ access_url(char *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ get_credentials(char *);
int message_extra_length(char *);
char *prepare_message(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int update_status(char *message) {
  char username_password[80];
  int message_excess = message_extra_length(message);
  if (message_excess > 0) {
    fprintf(stderr, "Your message is %d characters too long\n.",
            message_excess);
    return 1;
  } else {
    get_credentials(username_password);
    message = prepare_message(message);
    access_url(username_password, message, 2);
    free(message);
    printf("Updating status...\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<update_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <message_extra_length@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jle    11b6 <update_status+0x46>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x64(%rbp),%edx
lea    0xe5b(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fa <update_status+0x8a>
lea    -0x60(%rbp),%rdi
call   1060 <get_credentials@plt>
mov    -0x10(%rbp),%rdi
call   1080 <prepare_message@plt>
mov    %rax,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <access_url@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_status>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
call   1090 <message_extra_length@plt>
test   %eax,%eax
jle    11a1 <update_status+0x31>
mov    0x2e56(%rip),%rcx
mov    (%rcx),%edi
lea    0xe6d(%rip),%rsi
mov    %eax,%edx
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    11dd <update_status+0x6d>
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <get_credentials@plt>
mov    %rbx,%rdi
call   1080 <prepare_message@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2,%edx
call   1040 <access_url@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe53(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"Your message is %d characters too long\0A.\00"
@.str.1 = [20 x i8] c"Updating status...\0A\00"
define i32 @update_status(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [80 x i8]
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @message_extra_length(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* %5
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 1, i32* %2
br label %25
14: ; preds = %1
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%16 = call i32 @get_credentials(i8* %15)
%17 = load i8*, i8** %3
%18 = call i8* @prepare_message(i8* %17)
store i8* %18, i8** %3
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%20 = load i8*, i8** %3
%21 = call i32 @access_url(i8* %19, i8* %20, i32 2)
%22 = load i8*, i8** %3
%23 = call i32 @free(i8* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %25
25: ; preds = %14, %10
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Your message is %d characters too long\0A.\00"
@str = [19 x i8] c"Updating status...\00"
define i32 @update_status(i8* %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @message_extra_length(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %15
9: ; preds = %1
%10 = call i32 @get_credentials(i8* %3)
%11 = call i8* @prepare_message(i8* %0)
%12 = call i32 @access_url(i8* %3, i8* %11, i32 2)
%13 = call i32 @free(i8* %11)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %9, %6
%16 = phi i32 [ 1, %6 ], [ 0, %9 ]
ret i32 %16
}