#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int inform_user(char *);
int /*<<< orphan*/ stderr;
unsigned int strlen(char *);
int main(void) {
  int ret;
  char msg[] = "Hi there\n";
  ret = inform_user(msg);
  if (ret < 0) {
    fprintf(stderr, "Uh oh, output error is encountered\n");
  } else if ((unsigned int)ret != strlen(msg)) {
    fprintf(stderr, "Message was only partly printed\n");
    fprintf(stderr, " * Characters printed:     %d\n", ret);
    fprintf(stderr, " * Message length:         %lu\n", strlen(msg));
    fprintf(stderr, " * Remaining characters:   %lu\n",
            strlen(msg) - (unsigned int)ret);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x12(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0xa(%rbp)
lea    -0x12(%rbp),%rdi
call   1050 <inform_user@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1187 <main+0x57>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    122c <main+0xfc>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
je     1227 <main+0xf7>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%edx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
sub    -0x8(%rbp),%edx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    122c <main+0xfc>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x6572656874206948,%rax
65 72 65
mov    %rax,0x8(%rsp)
movw   $0xa,0x10(%rsp)
lea    0x8(%rsp),%rdi
call   1050 <inform_user@plt>
test   %eax,%eax
js     11e4 <main+0xb4>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
je     11fb <main+0xcb>
mov    0x2e63(%rip),%r15
mov    (%r15),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%edi
lea    0xeb7(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%ebp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0xeb6(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
sub    %ebx,%eax
lea    0xeb7(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11fb <main+0xcb>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.msg = [10 x i8] c"Hi there\0A\00"
@stderr = global i32 0
@.str = [36 x i8] c"Uh oh, output error is encountered\0A\00"
@.str.1 = [33 x i8] c"Message was only partly printed\0A\00"
@.str.2 = [31 x i8] c" * Characters printed: %d\0A\00"
@.str.3 = [32 x i8] c" * Message length: %lu\0A\00"
@.str.4 = [32 x i8] c" * Remaining characters: %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
store i32 0, i32* %1
%4 = bitcast [10 x i8]* %3 to i8*
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i32 @inform_user(i8* %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %34
12: ; preds = %0
%13 = load i32, i32* %2
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %33
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = load i32, i32* %2
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @stderr
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @stderr
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = load i32, i32* %2
%31 = sub i32 %29, %30
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %17, %12
br label %34
34: ; preds = %33, %9
ret i32 0
}

LLVM IR (-O2):
@__const.main.msg = [10 x i8] c"Hi there\0A\00"
@stderr = global i32 0
@.str = [36 x i8] c"Uh oh, output error is encountered\0A\00"
@.str.1 = [33 x i8] c"Message was only partly printed\0A\00"
@.str.2 = [31 x i8] c" * Characters printed: %d\0A\00"
@.str.3 = [32 x i8] c" * Message length: %lu\0A\00"
@.str.4 = [32 x i8] c" * Remaining characters: %lu\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @inform_user(i8* %2)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %23
8: ; preds = %0
%9 = call i32 @strlen(i8* %2)
%10 = icmp eq i32 %3, %9
br i1 %10, label %23, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%16 = load i32, i32* @stderr
%17 = call i32 @strlen(i8* %2)
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @stderr
%20 = call i32 @strlen(i8* %2)
%21 = sub i32 %20, %3
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %8, %11, %5
ret i32 0
}