#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*/ O_RDONLY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
char *strdup(char const *);
int check_and_open(const char *url, const char *document_root) {
  char *address;
  char *file;
  char temp[1024];
  int f;
  address = strdup(url);
  file = strdup(document_root);
  strcat(temp, file);
  strcat(temp, address);
  f = open(temp, O_RDONLY);
  if (f == -1) {
    fprintf(stderr, "Error open");
    return -1;
  }
  return f;
}


x86 assembly (clang, -O0):
<check_and_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x430(%rbp),%rdi
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x434(%rbp)
cmpl   $0xffffffff,-0x434(%rbp)
jne    11d6 <check_and_open+0x96>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <check_and_open+0x9f>
mov    -0x434(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_and_open>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
call   1060 <strdup@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <strdup@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11a3 <check_and_open+0x63>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1030 <fprintf@plt>
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"Error open\00"
define i32 @check_and_open(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [1024 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %6
%12 = load i8*, i8** %5
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %7
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%15 = load i8*, i8** %7
%16 = call i32 @strcat(i8* %14, i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%18 = load i8*, i8** %6
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* %20, i32 %21)
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %30
28: ; preds = %2
%29 = load i32, i32* %9
store i32 %29, i32* %3
br label %30
30: ; preds = %28, %25
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"Error open\00"
define i32 @check_and_open(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @strdup(i8* %0)
%6 = tail call i8* @strdup(i8* %1)
%7 = call i32 @strcat(i8* %4, i8* %6)
%8 = call i32 @strcat(i8* %4, i8* %5)
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* %4, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %2, %12
ret i32 %10
}