#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 */
struct svc_req {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int *abrir_1_svc(char *nom, struct svc_req *rqstp) {
  static int result;
  if ((result = open(nom, O_RDWR, 0)) == -1) {
    printf("Error en apertura de fichero para lectura %s\n", nom);
  } else {
    printf("Fichero %s abierto \n", nom);
  }
  return &result;
}


x86 assembly (clang, -O0):
<abrir_1_svc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <open@plt>
mov    %eax,0x2eea(%rip)
cmp    $0xffffffff,%eax
jne    1168 <abrir_1_svc+0x48>
mov    -0x8(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
jmp    1178 <abrir_1_svc+0x58>
mov    -0x8(%rbp),%rsi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
lea    0x2eb5(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abrir_1_svc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eba(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <open@plt>
mov    %eax,0x2ef7(%rip)
lea    0x2ef0(%rip),%r14
cmp    $0xffffffff,%eax
lea    0xeb2(%rip),%rax
lea    0xed9(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.svc_req = type { i32 }
@abrir_1_svc.result = internal global i32 0
@O_RDWR = global i32 0
@.str = [46 x i8] c"Error en apertura de fichero para lectura %s\0A\00"
@.str.1 = [21 x i8] c"Fichero %s abierto \0A\00"
define i32* @abrir_1_svc(i8* %0, %struct.svc_req* %1) {
%3 = alloca i8*
%4 = alloca %struct.svc_req*
store i8* %0, i8** %3
store %struct.svc_req* %1, %struct.svc_req** %4
%5 = load i8*, i8** %3
%6 = load i32, i32* @O_RDWR
%7 = call i32 @open(i8* %5, i32 %6, i32 0)
store i32 %7, i32* @abrir_1_svc.result
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %15
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %12, %9
ret i32* @abrir_1_svc.result
}

LLVM IR (-O2):
%struct.svc_req = type { i32 }
@abrir_1_svc.result = internal global i32 0
@O_RDWR = global i32 0
@.str = [46 x i8] c"Error en apertura de fichero para lectura %s\0A\00"
@.str.1 = [21 x i8] c"Fichero %s abierto \0A\00"
define i32* @abrir_1_svc(i8* %0, %struct.svc_req* nocapture readnone %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* %0, i32 %3, i32 0)
store i32 %4, i32* @abrir_1_svc.result
%5 = icmp eq i32 %4, -1
%6 = select i1 %5, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0)
%7 = tail call i32 @printf(i8* %6, i8* %0)
ret i32* @abrir_1_svc.result
}