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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, int);
int /*<<< orphan*/ strcmp(char *, char const *);
char *strtok(char *, char *);
const char *getOrdName(const char *file, const char *dll, int ord) {
  static char line[128];
  FILE *fp;
  char *kd, *ko, *kf;
  if ((fp = fopen(file, "r")) != NULL) {
    while (fgets(line, sizeof(line), fp) != NULL) {
      if (line[0] == ';')
        continue;
      kd = strtok(line, " \t.\n\r");
      ko = strtok(NULL, " \t.\n\r");
      kf = strtok(NULL, " \t.\n\r");
      if (!strcmp(kd, dll) && atoi(ko) == ord)
        return kf;
    }
    snprintf(line, sizeof(line), "%s:%d", dll, ord);
    return line;
  }
}


x86 assembly (clang, -O0):
<getOrdName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     126e <getOrdName+0x10e>
jmp    1196 <getOrdName+0x36>
mov    -0x28(%rbp),%rdx
lea    0x2ebf(%rip),%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1243 <getOrdName+0xe3>
movsbl 0x2ea4(%rip),%eax
cmp    $0x3b,%eax
jne    11ca <getOrdName+0x6a>
jmp    1196 <getOrdName+0x36>
lea    0x2e8f(%rip),%rdi
lea    0xe2a(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe16(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe02(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    123e <getOrdName+0xde>
mov    -0x38(%rbp),%rdi
call   1080 <atoi@plt>
cmp    -0x1c(%rbp),%eax
jne    123e <getOrdName+0xde>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    126e <getOrdName+0x10e>
jmp    1196 <getOrdName+0x36>
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    0x2e0e(%rip),%rdi
mov    $0x80,%esi
lea    0xdaa(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2df6(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOrdName>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
mov    %rsi,0x10(%rsp)
lea    0xe82(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     124e <getOrdName+0xee>
mov    %rax,%rbp
lea    0x2eca(%rip),%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1227 <getOrdName+0xc7>
lea    0x2ead(%rip),%r13
lea    0xe48(%rip),%rbx
jmp    11d5 <getOrdName+0x75>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x80,%esi
mov    %rbp,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1227 <getOrdName+0xc7>
cmpb   $0x3b,0x2e84(%rip)
je     11c0 <getOrdName+0x60>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <strtok@plt>
mov    %rax,%r12
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
mov    %rax,%r14
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11c0 <getOrdName+0x60>
mov    %r15,%rdi
call   1080 <atoi@plt>
cmp    0xc(%rsp),%eax
jne    11c0 <getOrdName+0x60>
jmp    124e <getOrdName+0xee>
lea    0xdda(%rip),%rdx
lea    0x2e2b(%rip),%r14
mov    %r14,%rdi
mov    $0x80,%esi
mov    0x10(%rsp),%rcx
mov    0xc(%rsp),%r8d
call   1030 <snprintf@plt>
jmp    124e <getOrdName+0xee>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@getOrdName.line = internal global [128 x i8] zeroinitializer
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c" \09.\0A\0D\00"
@.str.2 = [6 x i8] c"%s:%d\00"
define i8* @getOrdName(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %8
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %45
15: ; preds = %3
br label %16
16: ; preds = %40, %24, %15
%17 = load i32*, i32** %8
%18 = call i32* @fgets(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i32 128, i32* %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %41
20: ; preds = %16
%21 = load i8, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0)
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 59
br i1 %23, label %24, label %25
24: ; preds = %20
br label %16
25: ; preds = %20
%26 = call i8* @strtok(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %26, i8** %9
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %27, i8** %10
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %28, i8** %11
%29 = load i8*, i8** %9
%30 = load i8*, i8** %6
%31 = call i32 @strcmp(i8* %29, i8* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %25
%34 = load i8*, i8** %10
%35 = call i32 @atoi(i8* %34)
%36 = load i32, i32* %7
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = load i8*, i8** %11
store i8* %39, i8** %4
br label %45
40: ; preds = %33, %25
br label %16
41: ; preds = %16
%42 = load i8*, i8** %6
%43 = load i32, i32* %7
%44 = call i32 @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %42, i32 %43)
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i8** %4
br label %45
45: ; preds = %38, %41, %3
%46 = load i8*, i8** %4
ret i8* %46
}

LLVM IR (-O2):
@getOrdName.line = internal global [128 x i8] zeroinitializer
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c" \09.\0A\0D\00"
@.str.2 = [6 x i8] c"%s:%d\00"
define i8* @getOrdName(i8* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %26, label %6
6: ; preds = %3
%7 = tail call i32* @fgets(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i32 128, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %24, label %9
9: ; preds = %6, %21
%10 = load i8, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0)
%11 = icmp eq i8 %10, 59
br i1 %11, label %21, label %12
12: ; preds = %9
%13 = tail call i8* @strtok(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(1) %1)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = tail call i32 @atoi(i8* %14)
%20 = icmp eq i32 %19, %2
br i1 %20, label %26, label %21
21: ; preds = %12, %18, %9
%22 = tail call i32* @fgets(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i32 128, i32* %4)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %9
24: ; preds = %21, %6
%25 = tail call i32 @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %1, i32 %2)
br label %26
26: ; preds = %18, %3, %24
%27 = phi i8* [ getelementptr inbounds ([128 x i8], [128 x i8]* @getOrdName.line, i64 0, i64 0), %24 ], [ undef, %3 ], [ %15, %18 ]
ret i8* %27
}