#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*/ error(char *, int /*<<< orphan*/);
scalar_t__ load(char *);
int /*<<< orphan*/ make_string(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
int try_src(char *p, char *i) {
  char path[1024];
  if (strlen(p) + strlen(i) + 6 >= 1024) {
    error("source path too long", make_string(p, strlen(p)));
    return 0;
  }
  sprintf(path, "%s/%s.scm", p, i);
  return load(path) == 0;
}


x86 assembly (clang, -O0):
<try_src>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x424(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x424(%rbp),%eax
add    %ecx,%eax
add    $0x6,%eax
cmp    $0x400,%eax
jl     11cf <try_src+0x7f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x430(%rbp),%rdi
mov    %eax,%esi
call   1050 <make_string@plt>
mov    %eax,%esi
lea    0xe42(%rip),%rdi
call   1040 <error@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <try_src+0xb5>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe30(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1060 <load@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<try_src>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cmp    $0x3fa,%eax
jl     119d <try_src+0x4d>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <make_string@plt>
lea    0xe6e(%rip),%rdi
mov    %eax,%esi
call   1040 <error@plt>
xor    %eax,%eax
jmp    11c8 <try_src+0x78>
lea    0xe71(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1070 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <load@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"source path too long\00"
@.str.1 = [10 x i8] c"%s/%s.scm\00"
define i32 @try_src(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1024 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %8, %10
%12 = add nsw i32 %11, 6
%13 = icmp sge i32 %12, 1024
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @make_string(i8* %15, i32 %17)
%19 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %18)
store i32 0, i32* %3
br label %29
20: ; preds = %2
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %23)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%26 = call i64 @load(i8* %25)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
store i32 %28, i32* %3
br label %29
29: ; preds = %20, %14
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [21 x i8] c"source path too long\00"
@.str.1 = [10 x i8] c"%s/%s.scm\00"
define i32 @try_src(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* %1)
%7 = add nsw i32 %6, %5
%8 = icmp sgt i32 %7, 1017
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = tail call i32 @strlen(i8* %0)
%11 = tail call i32 @make_string(i8* %0, i32 %10)
%12 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %18
13: ; preds = %2
%14 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%15 = call i64 @load(i8* %4)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %13, %9
%19 = phi i32 [ 0, %9 ], [ %17, %13 ]
ret i32 %19
}