#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) {
  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/worksheet2/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/worksheet2/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/worksheet2/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/worksheet2/helper.c",
               szTmp);
  };
  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    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b2 <read_string+0x42>
mov    $0xa0,%edi
lea    0xe5a(%rip),%rsi
lea    0xee6(%rip),%rdx
call   1030 <errhandler@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11d5 <read_string+0x65>
mov    $0xa1,%edi
lea    0xe37(%rip),%rsi
lea    0xee7(%rip),%rdx
call   1030 <errhandler@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11f8 <read_string+0x88>
mov    $0xa2,%edi
lea    0xe14(%rip),%rsi
lea    0xee3(%rip),%rdx
call   1030 <errhandler@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    1222 <read_string+0xb2>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1090 <find_string@plt>
mov    %rax,-0x20(%rbp)
jmp    1233 <read_string+0xc3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <find_string@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeb3(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x0,%rax
jne    1287 <read_string+0x117>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe94(%rip),%rsi
lea    0xeab(%rip),%rdx
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x70(%rbp),%rdx
mov    $0xaa,%edi
lea    0xd7e(%rip),%rsi
call   1030 <errhandler@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0xf,%esi
call   1070 <min_int@plt>
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rdx
lea    0xe7c(%rip),%rcx
add    %rax,%rcx
mov    -0x18(%rbp),%r8
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
test   %rsi,%rsi
je     123e <read_string+0xce>
test   %r15,%r15
je     125f <read_string+0xef>
test   %r14,%r14
je     1280 <read_string+0x110>
xor    %esi,%esi
cmpb   $0x2a,(%rbx)
sete   %sil
add    %rbx,%rsi
mov    %r15,%rdi
call   1090 <find_string@plt>
lea    0xf3b(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <sscanf@plt>
test   %rax,%rax
jne    11ff <read_string+0x8f>
lea    0xf27(%rip),%rsi
lea    0xf3e(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe0e(%rip),%rsi
mov    $0xaa,%edi
mov    %r12,%rdx
call   1030 <errhandler@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0xf,%esi
call   1070 <min_int@plt>
lea    0xf1d(%rip),%rcx
add    %rax,%rcx
lea    0xeff(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%r8
call   1050 <printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdbb(%rip),%rsi
lea    0xe47(%rip),%rdx
mov    $0xa0,%edi
call   1030 <errhandler@plt>
test   %r15,%r15
jne    1196 <read_string+0x26>
lea    0xd9a(%rip),%rsi
lea    0xe4a(%rip),%rdx
mov    $0xa1,%edi
call   1030 <errhandler@plt>
test   %r14,%r14
jne    119f <read_string+0x2f>
lea    0xd79(%rip),%rsi
lea    0xe48(%rip),%rdx
mov    $0xa2,%edi
call   1030 <errhandler@plt>
jmp    119f <read_string+0x2f>

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/worksheet2/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) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [80 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* null, i8** %7
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = 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 %13
13: ; preds = %11, %3
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = 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 %18
18: ; preds = %16, %13
%19 = load i8*, i8** %6
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = 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 %23
23: ; preds = %21, %18
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 42
br i1 %28, label %29, label %34
29: ; preds = %23
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = call i8* @find_string(i8* %30, i8* %32)
store i8* %33, i8** %7
br label %38
34: ; preds = %23
%35 = load i8*, i8** %4
%36 = load i8*, i8** %5
%37 = call i8* @find_string(i8* %35, i8* %36)
store i8* %37, i8** %7
br label %38
38: ; preds = %34, %29
%39 = load i8*, i8** %7
%40 = load i8*, i8** %6
%41 = call i64 @sscanf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %38
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%45 = load i8*, i8** %4
%46 = load i8*, i8** %5
%47 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @sprintf(i8* %44, 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* %45, i8* %46)
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%49 = call i32 @errhandler(i32 170, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %43, %38
%51 = load i8*, i8** %4
%52 = load i8*, i8** %5
%53 = load i8*, i8** %5
%54 = call i64 @strlen(i8* %53)
%55 = trunc i64 %54 to i32
%56 = call i64 @min_int(i32 %55, i32 15)
%57 = getelementptr inbounds [16 x i8], [16 x i8]* @.str.8, i64 0, i64 %56
%58 = load i8*, i8** %6
%59 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %51, i8* %52, i8* %57, i8* %58)
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/worksheet2/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) {
%4 = alloca [80 x i8]
%5 = icmp eq i8* %1, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = 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 %8
8: ; preds = %6, %3
%9 = icmp eq i8* %0, null
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = 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 %12
12: ; preds = %10, %8
%13 = icmp eq i8* %2, null
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = 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 %16
16: ; preds = %14, %12
%17 = load i8, i8* %1
%18 = icmp eq i8 %17, 42
%19 = zext i1 %18 to i64
%20 = getelementptr i8, i8* %1, i64 %19
%21 = tail call i8* @find_string(i8* %0, i8* %20)
%22 = tail call i64 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %16
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%26 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @sprintf(i8* %25, 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)
%27 = call i32 @errhandler(i32 170, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %28
28: ; preds = %24, %16
%29 = call i64 @strlen(i8* %1)
%30 = trunc i64 %29 to i32
%31 = call i64 @min_int(i32 %30, i32 15)
%32 = getelementptr inbounds [16 x i8], [16 x i8]* @.str.8, i64 0, i64 %31
%33 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %0, i8* %1, i8* %32, i8* %2)
ret void
}