#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*/ error(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ lg(char *, char *);
void openfiles(FILE *fp[], char *fnames[], int nscores) {
  int f;
  for (f = 0; f < nscores; f++) {
    lg("Mixing %s\n", fnames[f]);
    if (NULL == (fp[f] = fopen(fnames[f], "rb")))
      error("Cant open");
  }
}


x86 assembly (clang, -O0):
<openfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bf <openfiles+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe97(%rip),%rdi
call   1030 <lg@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rdx
mov    %rcx,(%rax,%rdx,8)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ac <openfiles+0x7c>
lea    0xe67(%rip),%rdi
call   1040 <error@plt>
jmp    11b1 <openfiles+0x81>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <openfiles+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openfiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1198 <openfiles+0x68>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%ebp
xor    %r13d,%r13d
lea    0xeaf(%rip),%r15
lea    0xeb3(%rip),%r12
jmp    1169 <openfiles+0x39>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r13,%rbp
je     1198 <openfiles+0x68>
mov    (%rbx,%r13,8),%rsi
mov    %r15,%rdi
call   1030 <lg@plt>
mov    (%rbx,%r13,8),%rdi
mov    %r12,%rsi
call   1050 <fopen@plt>
mov    %rax,(%r14,%r13,8)
test   %rax,%rax
jne    1160 <openfiles+0x30>
lea    0xe7d(%rip),%rdi
call   1040 <error@plt>
jmp    1160 <openfiles+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Mixing %s\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [10 x i8] c"Cant open\00"
define void @openfiles(i32** %0, i8** %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32** %0, i32*** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %33, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %36
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @lg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8**, i8*** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32**, i32*** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32*, i32** %25, i64 %27
store i32* %24, i32** %28
%29 = icmp eq i32* null, %24
br i1 %29, label %30, label %32
30: ; preds = %12
%31 = call i32 @error(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %12
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %8
36: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Mixing %s\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [10 x i8] c"Cant open\00"
define void @openfiles(i32** nocapture writeonly %0, i8** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %21
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %18
%8 = phi i64 [ 0, %5 ], [ %19, %18 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32 @lg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %9
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds i32*, i32** %0, i64 %8
store i32* %13, i32** %14
%15 = icmp eq i32* %13, null
br i1 %15, label %16, label %18
16: ; preds = %7
%17 = tail call i32 @error(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %7, %16
%19 = add nuw nsw i64 %8, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %21, label %7
21: ; preds = %18, %3
ret void
}