#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 *);
scalar_t__ truncate(char *, int);
int main(void) {
  if (!truncate("tmp/foobar", 100)) {
    printf("/tmp/foobar should fail because foobar does not exist\n");
    return 1;
  }
  if (truncate("tmp/foo", 100)) {
    printf("/tmp/foo should not fail because foobar does not exist\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x64,%esi
call   1040 <truncate@plt>
cmp    $0x0,%rax
jne    1162 <main+0x42>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119c <main+0x7c>
lea    0xed9(%rip),%rdi
mov    $0x64,%esi
call   1040 <truncate@plt>
cmp    $0x0,%rax
je     1195 <main+0x75>
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119c <main+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x64,%esi
call   1040 <truncate@plt>
test   %rax,%rax
je     1156 <main+0x36>
lea    0xecd(%rip),%rdi
mov    $0x64,%esi
call   1040 <truncate@plt>
test   %rax,%rax
je     1169 <main+0x49>
lea    0xef5(%rip),%rdi
jmp    115d <main+0x3d>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"tmp/foobar\00"
@.str.1 = [55 x i8] c"/tmp/foobar should fail because foobar does not exist\0A\00"
@.str.2 = [8 x i8] c"tmp/foo\00"
@.str.3 = [56 x i8] c"/tmp/foo should not fail because foobar does not exist\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @truncate(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 100)
%3 = icmp ne i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %12
6: ; preds = %0
%7 = call i64 @truncate(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 100)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %12
11: ; preds = %6
store i32 0, i32* %1
br label %12
12: ; preds = %11, %9, %4
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [11 x i8] c"tmp/foobar\00"
@.str.2 = [8 x i8] c"tmp/foo\00"
@str = [54 x i8] c"/tmp/foobar should fail because foobar does not exist\00"
@str.4 = [55 x i8] c"/tmp/foo should not fail because foobar does not exist\00"
define i32 @main() {
%1 = tail call i64 @truncate(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 100)
%2 = icmp eq i64 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i64 @truncate(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 100)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3, %0
%7 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.4, i64 0, i64 0), %3 ]
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ 0, %3 ], [ 1, %6 ]
ret i32 %10
}