#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int get_strings(int num, char **in_str, int *in_label, char *filename) {
  int i, test, mlen = 0;
  char str[100];
  FILE *in;
  in = fopen(filename, "r");
  if (in == NULL) {
    printf("\n\tCan't open %s to get strings\n");
    exit(1);
  }
  for (i = 0; i < num; i++)
    in_label[i] = (-1);
  for (i = 0; i < num; i++) {
    test = fscanf(in, "%d %s", in_label + i, in_str[i]);
    if (test != 2) {
      printf("\n\tProblem reading string file %s\n", filename);
      exit(1);
    }
    if (mlen < strlen(in_str[i]))
      mlen = strlen(in_str[i]);
  }
  fclose(in);
  return mlen;
}


x86 assembly (clang, -O0):
<get_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    11be <get_strings+0x5e>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ee <get_strings+0x8e>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c5 <get_strings+0x65>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12a9 <get_strings+0x149>
mov    -0x98(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xdf8(%rip),%rsi
call   1060 <fscanf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x2,-0x28(%rbp)
je     1258 <get_strings+0xf8>
mov    -0x20(%rbp),%rsi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
cmp    %ecx,%eax
jge    1296 <get_strings+0x136>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
jmp    129b <get_strings+0x13b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f5 <get_strings+0x95>
mov    -0x98(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x2c(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_strings>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe73(%rip),%rsi
mov    %rcx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1246 <get_strings+0xd6>
mov    %rax,%r12
test   %ebp,%ebp
jle    120f <get_strings+0x9f>
mov    %r14,(%rsp)
mov    %ebp,%r13d
shl    $0x2,%r13
mov    %r15,%rdi
mov    $0xff,%esi
mov    %r13,%rdx
call   1060 <memset@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    11d9 <get_strings+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x4,%r14
cmp    %r14,%r13
je     1211 <get_strings+0xa1>
lea    (%r15,%r14,1),%rdx
mov    (%rbx,%r14,2),%rcx
mov    %r12,%rdi
lea    0xe37(%rip),%rsi
call   1070 <fscanf@plt>
cmp    $0x2,%eax
jne    122a <get_strings+0xba>
mov    (%rbx,%r14,2),%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jge    11d0 <get_strings+0x60>
mov    (%rbx,%r14,2),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
jmp    11d0 <get_strings+0x60>
xor    %ebp,%ebp
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf7(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xdb5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"\0A\09Can't open %s to get strings\0A\00"
@.str.2 = [6 x i8] c"%d %s\00"
@.str.3 = [34 x i8] c"\0A\09Problem reading string file %s\0A\00"
define i32 @get_strings(i32 %0, i8** %1, i32* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [100 x i8]
%13 = alloca i32*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i8* %3, i8** %8
store i32 0, i32* %11
%14 = load i8*, i8** %8
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %13
%16 = load i32*, i32** %13
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %4
store i32 0, i32* %9
br label %22
22: ; preds = %31, %21
%23 = load i32, i32* %9
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %22
%27 = load i32*, i32** %7
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 -1, i32* %30
br label %31
31: ; preds = %26
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %22
34: ; preds = %22
store i32 0, i32* %9
br label %35
35: ; preds = %74, %34
%36 = load i32, i32* %9
%37 = load i32, i32* %5
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %77
39: ; preds = %35
%40 = load i32*, i32** %13
%41 = load i32*, i32** %7
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i8**, i8*** %6
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @fscanf(i32* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %44, i8* %49)
store i32 %50, i32* %10
%51 = load i32, i32* %10
%52 = icmp ne i32 %51, 2
br i1 %52, label %53, label %57
53: ; preds = %39
%54 = load i8*, i8** %8
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %54)
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %39
%58 = load i32, i32* %11
%59 = load i8**, i8*** %6
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 @strlen(i8* %63)
%65 = icmp slt i32 %58, %64
br i1 %65, label %66, label %73
66: ; preds = %57
%67 = load i8**, i8*** %6
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = call i32 @strlen(i8* %71)
store i32 %72, i32* %11
br label %73
73: ; preds = %66, %57
br label %74
74: ; preds = %73
%75 = load i32, i32* %9
%76 = add nsw i32 %75, 1
store i32 %76, i32* %9
br label %35
77: ; preds = %35
%78 = load i32*, i32** %13
%79 = call i32 @fclose(i32* %78)
%80 = load i32, i32* %11
ret i32 %80
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"\0A\09Can't open %s to get strings\0A\00"
@.str.2 = [6 x i8] c"%d %s\00"
@.str.3 = [34 x i8] c"\0A\09Problem reading string file %s\0A\00"
define i32 @get_strings(i32 %0, i8** nocapture %1, i32* %2, i8* %3) {
%5 = bitcast i32* %2 to i8*
%6 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = icmp sgt i32 %0, 0
br i1 %9, label %13, label %39
10: ; preds = %4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %8
%14 = zext i32 %0 to i64
%15 = shl nuw nsw i64 %14, 2
%16 = zext i32 %0 to i64
br label %17
17: ; preds = %13, %35
%18 = phi i64 [ 0, %13 ], [ %37, %35 ]
%19 = phi i32 [ 0, %13 ], [ %36, %35 ]
%20 = getelementptr inbounds i32, i32* %2, i64 %18
%21 = getelementptr inbounds i8*, i8** %1, i64 %18
%22 = load i8*, i8** %21
%23 = tail call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %20, i8* %22)
%24 = icmp eq i32 %23, 2
br i1 %24, label %28, label %25
25: ; preds = %17
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %17
%29 = load i8*, i8** %21
%30 = tail call i32 @strlen(i8* %29)
%31 = icmp slt i32 %19, %30
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i8*, i8** %21
%34 = tail call i32 @strlen(i8* %33)
br label %35
35: ; preds = %28, %32
%36 = phi i32 [ %34, %32 ], [ %19, %28 ]
%37 = add nuw nsw i64 %18, 1
%38 = icmp eq i64 %37, %16
br i1 %38, label %39, label %17
39: ; preds = %35, %8
%40 = phi i32 [ 0, %8 ], [ %36, %35 ]
%41 = tail call i32 @fclose(i32* %6)
ret i32 %40
}