#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 */

/* Variables and functions */
int /*<<< orphan*/ errhandler(int, char *, char *);
char *find_string(char const *, char const *);
size_t min_int(int, int);
int /*<<< orphan*/ printf(char *, char const *, char const *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char const *, char const *,
                           ...);
scalar_t__ sscanf(char *, char *, char *);
scalar_t__ strlen(char const *);
void read_string(const char *szFileName, const char *szVarName, char *pVariable,
                 int my_rank) {
  char *szValue = NULL;
  if (szVarName == 0)
    errhandler(160,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/"
               "heads/master/worksheet4/helper.c",
               "null pointer given as variable name");
  if (szFileName == 0)
    errhandler(161,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/"
               "heads/master/worksheet4/helper.c",
               "null pointer given as filename");
  if (pVariable == 0)
    errhandler(162,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/"
               "heads/master/worksheet4/helper.c",
               "null pointer given as variable");
  if (szVarName[0] == '*')
    szValue = find_string(szFileName, szVarName + 1);
  else
    szValue = find_string(szFileName, szVarName);
  if (sscanf(szValue, "%s", pVariable) == 0) {
    char szTmp[80];
    if (0)
      sprintf(szTmp, " %s  File: %s   Variable: %s  Line: %d", "wrong format",
              szFileName, szVarName, 0);
    else
      sprintf(szTmp, " %s  File: %s   Variable: %s ", "wrong format",
              szFileName, szVarName);
    errhandler(170,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/"
               "heads/master/worksheet4/helper.c",
               szTmp);
  };
  if (my_rank == 0)
    printf("File: %s\t\t%s%s= %s\n", szFileName, szVarName,
           &("               "[min_int((int)strlen(szVarName), 15)]),
           pVariable);
}


x86 assembly (clang, -O0):
<read_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b5 <read_string+0x45>
mov    $0xa0,%edi
lea    0xe57(%rip),%rsi
lea    0xee3(%rip),%rdx
call   1030 <errhandler@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11d8 <read_string+0x68>
mov    $0xa1,%edi
lea    0xe34(%rip),%rsi
lea    0xee4(%rip),%rdx
call   1030 <errhandler@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11fb <read_string+0x8b>
mov    $0xa2,%edi
lea    0xe11(%rip),%rsi
lea    0xee0(%rip),%rdx
call   1030 <errhandler@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    1225 <read_string+0xb5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1090 <find_string@plt>
mov    %rax,-0x28(%rbp)
jmp    1236 <read_string+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <find_string@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeb0(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x0,%rax
jne    128a <read_string+0x11a>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe91(%rip),%rsi
lea    0xea8(%rip),%rdx
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x80(%rbp),%rdx
mov    $0xaa,%edi
lea    0xd7b(%rip),%rsi
call   1030 <errhandler@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12e7 <read_string+0x177>
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0xf,%esi
call   1070 <min_int@plt>
mov    -0x90(%rbp),%rsi
mov    -0x88(%rbp),%rdx
lea    0xe63(%rip),%rcx
add    %rax,%rcx
mov    -0x18(%rbp),%r8
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
test   %rsi,%rsi
je     11d6 <read_string+0x66>
test   %r15,%r15
je     11f3 <read_string+0x83>
test   %r14,%r14
je     1210 <read_string+0xa0>
xor    %esi,%esi
cmpb   $0x2a,(%rbx)
sete   %sil
add    %rbx,%rsi
mov    %r15,%rdi
call   1090 <find_string@plt>
lea    0xf44(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <sscanf@plt>
test   %rax,%rax
je     122d <read_string+0xbd>
test   %ebp,%ebp
je     126a <read_string+0xfa>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe23(%rip),%rsi
lea    0xeaf(%rip),%rdx
mov    $0xa0,%edi
call   1030 <errhandler@plt>
test   %r15,%r15
jne    1191 <read_string+0x21>
lea    0xe06(%rip),%rsi
lea    0xeb6(%rip),%rdx
mov    $0xa1,%edi
call   1030 <errhandler@plt>
test   %r14,%r14
jne    1196 <read_string+0x26>
lea    0xde9(%rip),%rsi
lea    0xeb8(%rip),%rdx
mov    $0xa2,%edi
call   1030 <errhandler@plt>
jmp    1196 <read_string+0x26>
lea    0xec4(%rip),%rsi
lea    0xedb(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xdab(%rip),%rsi
mov    $0xaa,%edi
mov    %r12,%rdx
call   1030 <errhandler@plt>
test   %ebp,%ebp
jne    11c9 <read_string+0x59>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0xf,%esi
call   1070 <min_int@plt>
lea    0xeb2(%rip),%rcx
add    %rax,%rcx
lea    0xe94(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%r8
call   1050 <printf@plt>
jmp    11c9 <read_string+0x59>

LLVM IR (-O0):
@.str = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/heads/master/worksheet4/helper.c\00"
@.str.1 = [36 x i8] c"null pointer given as variable name\00"
@.str.2 = [31 x i8] c"null pointer given as filename\00"
@.str.3 = [31 x i8] c"null pointer given as variable\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [30 x i8] c" %s File: %s Variable: %s \00"
@.str.6 = [13 x i8] c"wrong format\00"
@.str.7 = [20 x i8] c"File: %s\09\09%s%s= %s\0A\00"
@.str.8 = [16 x i8] c" \00"
define void @read_string(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [80 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i8* null, i8** %9
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = call i32 @errhandler(i32 160, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
%16 = load i8*, i8** %5
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @errhandler(i32 161, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
%21 = load i8*, i8** %7
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @errhandler(i32 162, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 42
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = load i8*, i8** %5
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = call i8* @find_string(i8* %32, i8* %34)
store i8* %35, i8** %9
br label %40
36: ; preds = %25
%37 = load i8*, i8** %5
%38 = load i8*, i8** %6
%39 = call i8* @find_string(i8* %37, i8* %38)
store i8* %39, i8** %9
br label %40
40: ; preds = %36, %31
%41 = load i8*, i8** %9
%42 = load i8*, i8** %7
%43 = call i64 @sscanf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %52
45: ; preds = %40
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%47 = load i8*, i8** %5
%48 = load i8*, i8** %6
%49 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @sprintf(i8* %46, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %47, i8* %48)
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%51 = call i32 @errhandler(i32 170, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %45, %40
%53 = load i32, i32* %8
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %65
55: ; preds = %52
%56 = load i8*, i8** %5
%57 = load i8*, i8** %6
%58 = load i8*, i8** %6
%59 = call i64 @strlen(i8* %58)
%60 = trunc i64 %59 to i32
%61 = call i64 @min_int(i32 %60, i32 15)
%62 = getelementptr inbounds [16 x i8], [16 x i8]* @.str.8, i64 0, i64 %61
%63 = load i8*, i8** %7
%64 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %56, i8* %57, i8* %62, i8* %63)
br label %65
65: ; preds = %55, %52
ret void
}

LLVM IR (-O2):
@.str = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nathanwbrei/cfdlab/refs/heads/master/worksheet4/helper.c\00"
@.str.1 = [36 x i8] c"null pointer given as variable name\00"
@.str.2 = [31 x i8] c"null pointer given as filename\00"
@.str.3 = [31 x i8] c"null pointer given as variable\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [30 x i8] c" %s File: %s Variable: %s \00"
@.str.6 = [13 x i8] c"wrong format\00"
@.str.7 = [20 x i8] c"File: %s\09\09%s%s= %s\0A\00"
@.str.8 = [16 x i8] c" \00"
define void @read_string(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [80 x i8]
%6 = icmp eq i8* %1, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @errhandler(i32 160, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = icmp eq i8* %0, null
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @errhandler(i32 161, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = icmp eq i8* %2, null
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @errhandler(i32 162, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = load i8, i8* %1
%19 = icmp eq i8 %18, 42
%20 = zext i1 %19 to i64
%21 = getelementptr i8, i8* %1, i64 %20
%22 = tail call i8* @find_string(i8* %0, i8* %21)
%23 = tail call i64 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%27 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %1)
%28 = call i32 @errhandler(i32 170, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %29
29: ; preds = %25, %17
%30 = icmp eq i32 %3, 0
br i1 %30, label %31, label %37
31: ; preds = %29
%32 = call i64 @strlen(i8* %1)
%33 = trunc i64 %32 to i32
%34 = call i64 @min_int(i32 %33, i32 15)
%35 = getelementptr inbounds [16 x i8], [16 x i8]* @.str.8, i64 0, i64 %34
%36 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %0, i8* %1, i8* %35, i8* %2)
br label %37
37: ; preds = %31, %29
ret void
}