#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*/ printf(char *, char, int);
void check_string(char *line, int (*cmp_f)(int c)) {
  int i = 0;
  int rez = 0;
  while (*(line + i) != '\0') {
    rez = cmp_f(*(line + i));
    printf("rez of '%c' = %d;\n", *(line + i), rez);
    i++;
  }
}


x86 assembly (clang, -O0):
<check_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1183 <check_string+0x73>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movsbl (%rcx,%rdx,1),%edi
call   *%rax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%edx
lea    0xe93(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <check_string+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_string>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     114f <check_string+0x3f>
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xed4(%rip),%r15
nopl   0x0(%rax)
movsbl %al,%edi
call   *%r14
movsbl -0x1(%rbx),%esi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <check_string+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"rez of '%c' = %d;\0A\00"
define void @check_string(i8* %0, i32 (i32)* %1) {
%3 = alloca i8*
%4 = alloca i32 (i32)*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 (i32)* %1, i32 (i32)** %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %15, %2
%8 = load i8*, i8** %3
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %33
15: ; preds = %7
%16 = load i32 (i32)*, i32 (i32)** %4
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = call i32 %16(i32 %22)
store i32 %23, i32* %6
%24 = load i8*, i8** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = load i32, i32* %6
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext %28, i32 %29)
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %7
33: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"rez of '%c' = %d;\0A\00"
define void @check_string(i8* nocapture %0, i32 (i32)* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %13, %5 ], [ 0, %2 ]
%7 = phi i8 [ %15, %5 ], [ %3, %2 ]
%8 = phi i8* [ %14, %5 ], [ %0, %2 ]
%9 = sext i8 %7 to i32
%10 = tail call i32 %1(i32 %9)
%11 = load i8, i8* %8
%12 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext %11, i32 %10)
%13 = add nuw i64 %6, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %5, %2
ret void
}