#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 uint16_t;
typedef scalar_t__ int8_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ pCT_close(int);
scalar_t__ pCT_init(int, int);
int /*<<< orphan*/ printf(char *, scalar_t__);
int /*<<< orphan*/ stderr;
scalar_t__ test_geldkarte(int);
int multi_test(char *argv0, int pn, int readers, int count) {
  int i;
  uint16_t ctn = 1;
  int errs = 0;
  for (i = 1; i <= readers; i++) {
    int8_t ret;
    int err = 0;
    ret = pCT_init(ctn, i);
    if (ret != 0) {
      printf("  Error doing CT_init. (Return code:%d)\n", ret);
      err = 1;
    } else {
      int j;
      for (j = 0; j < count; j++) {
        ret = test_geldkarte(ctn);
        if (ret) {
          err = 1;
          break;
        }
      }
      ret = pCT_close(ctn);
      if (ret != 0) {
        printf("  Error doing CT_init. (Return code:%d)\n", ret);
        err = 1;
      }
    }
    if (err) {
      fprintf(stderr, "-> Reader %d: FAILED\n", i);
      errs++;
    } else {
      fprintf(stderr, "-> Reader %d: Success\n", i);
    }
  }
  if (errs) {
    if (errs == readers) {
      fprintf(stderr, "FAILED: All tests failed.\n");
    } else {
      fprintf(stderr, "FAILED: Some tests failed.\n");
    }
    return 2;
  }
  fprintf(stderr, "SUCCESS: All tests ok.\n");
  return 0;
}


x86 assembly (clang, -O0):
<multi_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     129e <multi_test+0x14e>
movl   $0x0,-0x34(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <pCT_init@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11c3 <multi_test+0x73>
mov    -0x30(%rbp),%rsi
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
jmp    123f <multi_test+0xef>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120c <multi_test+0xbc>
mov    -0x24(%rbp),%edi
call   1050 <test_geldkarte@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11f9 <multi_test+0xa9>
movl   $0x1,-0x34(%rbp)
jmp    120c <multi_test+0xbc>
jmp    11fe <multi_test+0xae>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11ca <multi_test+0x7a>
mov    -0x24(%rbp),%edi
call   1070 <pCT_close@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     123a <multi_test+0xea>
mov    -0x30(%rbp),%rsi
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
jmp    123f <multi_test+0xef>
cmpl   $0x0,-0x34(%rbp)
je     1271 <multi_test+0x121>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    128b <multi_test+0x13b>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1290 <multi_test+0x140>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117a <multi_test+0x2a>
cmpl   $0x0,-0x28(%rbp)
je     12f3 <multi_test+0x1a3>
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    12d0 <multi_test+0x180>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
lea    0xd92(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12e7 <multi_test+0x197>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1311 <multi_test+0x1c1>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
lea    0xd8a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1271 <multi_test+0x121>
mov    %ecx,%r15d
mov    %edx,%r14d
mov    $0x1,%ebx
mov    0x2e6b(%rip),%rbp
xor    %r13d,%r13d
jmp    119e <multi_test+0x4e>
mov    0x0(%rbp),%edi
lea    0xebb(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
nopl   (%rax)
lea    0x1(%rbx),%eax
cmp    %r14d,%ebx
mov    %eax,%ebx
je     125b <multi_test+0x10b>
mov    $0x1,%edi
mov    %ebx,%esi
call   1040 <pCT_init@plt>
test   %rax,%rax
je     11e0 <multi_test+0x90>
lea    0xe4a(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    0x0(%rbp),%edi
lea    0xe61(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%r13d
jmp    1190 <multi_test+0x40>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
test   %r15d,%r15d
jle    1248 <multi_test+0xf8>
call   1050 <test_geldkarte@plt>
mov    $0x1,%r12b
test   %rax,%rax
jne    1227 <multi_test+0xd7>
mov    $0x1,%ecx
nopl   0x0(%rax)
mov    %ecx,%ebp
cmp    %ecx,%r15d
je     1219 <multi_test+0xc9>
mov    $0x1,%edi
call   1050 <test_geldkarte@plt>
lea    0x1(%rbp),%ecx
test   %rax,%rax
je     1200 <multi_test+0xb0>
cmp    %r15d,%ebp
setl   %r12b
mov    0x2db9(%rip),%rbp
mov    $0x1,%edi
call   1070 <pCT_close@plt>
test   %rax,%rax
jne    11af <multi_test+0x5f>
test   %r12b,%r12b
je     117a <multi_test+0x2a>
jmp    11be <multi_test+0x6e>
call   1070 <pCT_close@plt>
test   %rax,%rax
jne    11af <multi_test+0x5f>
jmp    117a <multi_test+0x2a>
test   %r13d,%r13d
je     1271 <multi_test+0x121>
mov    0x0(%rbp),%edi
cmp    %r14d,%r13d
jne    128c <multi_test+0x13c>
lea    0xde7(%rip),%rsi
jmp    1293 <multi_test+0x143>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    129f <multi_test+0x14f>
lea    0xdde(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c" Error doing CT_init. (Return code:%d)\0A\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"-> Reader %d: FAILED\0A\00"
@.str.2 = [23 x i8] c"-> Reader %d: Success\0A\00"
@.str.3 = [27 x i8] c"FAILED: All tests failed.\0A\00"
@.str.4 = [28 x i8] c"FAILED: Some tests failed.\0A\00"
@.str.5 = [24 x i8] c"SUCCESS: All tests ok.\0A\00"
define i32 @multi_test(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 1, i32* %11
store i32 0, i32* %12
store i32 1, i32* %10
br label %16
16: ; preds = %67, %4
%17 = load i32, i32* %10
%18 = load i32, i32* %8
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %70
20: ; preds = %16
store i32 0, i32* %14
%21 = load i32, i32* %11
%22 = load i32, i32* %10
%23 = call i64 @pCT_init(i32 %21, i32 %22)
store i64 %23, i64* %13
%24 = load i64, i64* %13
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i64, i64* %13
%28 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 %27)
store i32 1, i32* %14
br label %53
29: ; preds = %20
store i32 0, i32* %15
br label %30
30: ; preds = %41, %29
%31 = load i32, i32* %15
%32 = load i32, i32* %9
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %44
34: ; preds = %30
%35 = load i32, i32* %11
%36 = call i64 @test_geldkarte(i32 %35)
store i64 %36, i64* %13
%37 = load i64, i64* %13
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 1, i32* %14
br label %44
40: ; preds = %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %15
%43 = add nsw i32 %42, 1
store i32 %43, i32* %15
br label %30
44: ; preds = %39, %30
%45 = load i32, i32* %11
%46 = call i64 @pCT_close(i32 %45)
store i64 %46, i64* %13
%47 = load i64, i64* %13
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i64, i64* %13
%51 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 %50)
store i32 1, i32* %14
br label %52
52: ; preds = %49, %44
br label %53
53: ; preds = %52, %26
%54 = load i32, i32* %14
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load i32, i32* @stderr
%58 = load i32, i32* %10
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %12
%61 = add nsw i32 %60, 1
store i32 %61, i32* %12
br label %66
62: ; preds = %53
%63 = load i32, i32* @stderr
%64 = load i32, i32* %10
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %62, %56
br label %67
67: ; preds = %66
%68 = load i32, i32* %10
%69 = add nsw i32 %68, 1
store i32 %69, i32* %10
br label %16
70: ; preds = %16
%71 = load i32, i32* %12
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %84
73: ; preds = %70
%74 = load i32, i32* %12
%75 = load i32, i32* %8
%76 = icmp eq i32 %74, %75
br i1 %76, label %77, label %80
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %83
80: ; preds = %73
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %83
83: ; preds = %80, %77
store i32 2, i32* %5
br label %87
84: ; preds = %70
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %5
br label %87
87: ; preds = %84, %83
%88 = load i32, i32* %5
ret i32 %88
}

LLVM IR (-O2):
@.str = [41 x i8] c" Error doing CT_init. (Return code:%d)\0A\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"-> Reader %d: FAILED\0A\00"
@.str.2 = [23 x i8] c"-> Reader %d: Success\0A\00"
@.str.3 = [27 x i8] c"FAILED: All tests failed.\0A\00"
@.str.4 = [28 x i8] c"FAILED: Some tests failed.\0A\00"
@.str.5 = [24 x i8] c"SUCCESS: All tests ok.\0A\00"
define i32 @multi_test(i8* nocapture readnone %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %2, 1
br i1 %5, label %57, label %6
6: ; preds = %4
%7 = icmp sgt i32 %3, 0
br label %8
8: ; preds = %6, %44
%9 = phi i32 [ 0, %6 ], [ %45, %44 ]
%10 = phi i32 [ 1, %6 ], [ %46, %44 ]
%11 = tail call i64 @pCT_init(i32 1, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %8
br i1 %7, label %14, label %30
14: ; preds = %13
%15 = tail call i64 @test_geldkarte(i32 1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %14, %20
%18 = phi i32 [ %23, %20 ], [ 1, %14 ]
%19 = icmp eq i32 %18, %3
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = tail call i64 @test_geldkarte(i32 1)
%22 = icmp eq i64 %21, 0
%23 = add nuw nsw i32 %18, 1
br i1 %22, label %17, label %24
24: ; preds = %17, %20
%25 = icmp slt i32 %18, %3
br label %26
26: ; preds = %24, %14
%27 = phi i1 [ true, %14 ], [ %25, %24 ]
%28 = tail call i64 @pCT_close(i32 1)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %34
30: ; preds = %13
%31 = tail call i64 @pCT_close(i32 1)
%32 = icmp eq i64 %31, 0
br i1 %32, label %41, label %34
33: ; preds = %26
br i1 %27, label %37, label %41
34: ; preds = %26, %30, %8
%35 = phi i64 [ %11, %8 ], [ %31, %30 ], [ %28, %26 ]
%36 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 %35)
br label %37
37: ; preds = %34, %33
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%40 = add nsw i32 %9, 1
br label %44
41: ; preds = %30, %33
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %44
44: ; preds = %41, %37
%45 = phi i32 [ %40, %37 ], [ %9, %41 ]
%46 = add nuw i32 %10, 1
%47 = icmp eq i32 %10, %2
br i1 %47, label %48, label %8
48: ; preds = %44
%49 = icmp eq i32 %45, 0
br i1 %49, label %57, label %50
50: ; preds = %48
%51 = icmp eq i32 %45, %2
%52 = load i32, i32* @stderr
br i1 %51, label %53, label %55
53: ; preds = %50
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %60
55: ; preds = %50
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %60
57: ; preds = %4, %48
%58 = load i32, i32* @stderr
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %60
60: ; preds = %53, %55, %57
%61 = phi i32 [ 0, %57 ], [ 2, %55 ], [ 2, %53 ]
ret i32 %61
}