#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 act(int *, char const, int *, char const);
int str_act(int *s1, const char *a1, int *s2, const char *a2) {
  for (; *a1 && *a2; ++a1, ++a2) {
    int winner = act(s1, *a1, s2, *a2);
    if (winner)
      return winner;
  }
  return 0;
}


x86 assembly (clang, -O0):
<str_act>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
je     114d <str_act+0x3d>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    115d <str_act+0x4d>
jmp    11b4 <str_act+0xa4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rax
movsbl %cl,%esi
movsbl (%rax),%ecx
call   1030 <act@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1192 <str_act+0x82>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bb <str_act+0xab>
jmp    1197 <str_act+0x87>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1128 <str_act+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_act>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rsi),%al
test   %al,%al
je     116d <str_act+0x5d>
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r13
xor    %r14d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r12,%rbp,1),%ecx
test   %cl,%cl
je     1175 <str_act+0x65>
movsbl %al,%esi
movsbl %cl,%ecx
mov    %r13,%rdi
mov    %r15,%rdx
call   1030 <act@plt>
test   %eax,%eax
jne    1172 <str_act+0x62>
movzbl 0x1(%rbx,%rbp,1),%eax
add    $0x1,%rbp
test   %al,%al
jne    1140 <str_act+0x30>
jmp    1175 <str_act+0x65>
xor    %r14d,%r14d
jmp    1175 <str_act+0x65>
mov    %eax,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @str_act(i32* %0, i8* %1, i32* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
br label %11
11: ; preds = %36, %4
%12 = load i8*, i8** %7
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i8*, i8** %9
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %16, %11
%22 = phi i1 [ false, %11 ], [ %20, %16 ]
br i1 %22, label %23, label %41
23: ; preds = %21
%24 = load i32*, i32** %6
%25 = load i8*, i8** %7
%26 = load i8, i8* %25
%27 = load i32*, i32** %8
%28 = load i8*, i8** %9
%29 = load i8, i8* %28
%30 = call i32 @act(i32* %24, i8 signext %26, i32* %27, i8 signext %29)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %23
%34 = load i32, i32* %10
store i32 %34, i32* %5
br label %42
35: ; preds = %23
br label %36
36: ; preds = %35
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %7
%39 = load i8*, i8** %9
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %9
br label %11
41: ; preds = %21
store i32 0, i32* %5
br label %42
42: ; preds = %41, %33
%43 = load i32, i32* %5
ret i32 %43
}

LLVM IR (-O2):
define i32 @str_act(i32* %0, i8* nocapture %1, i32* %2, i8* nocapture %3) {
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %4, %16
%8 = phi i8 [ %19, %16 ], [ %5, %4 ]
%9 = phi i8* [ %18, %16 ], [ %3, %4 ]
%10 = phi i8* [ %17, %16 ], [ %1, %4 ]
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %7
%14 = tail call i32 @act(i32* %0, i8 signext %8, i32* %2, i8 signext %11)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %10, i64 1
%18 = getelementptr inbounds i8, i8* %9, i64 1
%19 = load i8, i8* %17
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %7
21: ; preds = %16, %7, %13, %4
%22 = phi i32 [ 0, %4 ], [ %14, %13 ], [ 0, %7 ], [ 0, %16 ]
ret i32 %22
}