#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char *);
FILE *ouvrir(char *a, char *b) {
  if ((strcmp(a, "-") == 0) && (strcmp(b, "r") == 0))
    return stdin;
  else {
    FILE *f = fopen(a, b);
    if (!f) {
      fprintf(stderr, "Can't open %s\n", a);
      exit(1);
    }
    return f;
  }
}


x86 assembly (clang, -O0):
<ouvrir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1197 <ouvrir+0x57>
mov    -0x18(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1197 <ouvrir+0x57>
mov    0x2e5d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11de <ouvrir+0x9e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d6 <ouvrir+0x96>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe3d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ouvrir>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeaf(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    116f <ouvrir+0x2f>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1187 <ouvrir+0x47>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1193 <ouvrir+0x53>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e5a(%rip),%rax
mov    (%rax),%rax
jmp    117f <ouvrir+0x3f>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32* null
@stderr = global i32 0
@.str.2 = [15 x i8] c"Can't open %s\0A\00"
define i32* @ouvrir(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = load i32*, i32** @stdin
store i32* %15, i32** %3
br label %29
16: ; preds = %10, %2
%17 = load i8*, i8** %4
%18 = load i8*, i8** %5
%19 = call i32* @fopen(i8* %17, i8* %18)
store i32* %19, i32** %6
%20 = load i32*, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %27, label %22
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %4
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %16
%28 = load i32*, i32** %6
store i32* %28, i32** %3
br label %29
29: ; preds = %27, %14
%30 = load i32*, i32** %3
ret i32* %30
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32* null
@stderr = global i32 0
@.str.2 = [15 x i8] c"Can't open %s\0A\00"
define i32* @ouvrir(i8* %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = load i32*, i32** @stdin
br label %17
10: ; preds = %5, %2
%11 = tail call i32* @fopen(i8* %0, i8* %1)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10, %8
%18 = phi i32* [ %9, %8 ], [ %11, %10 ]
ret i32* %18
}