#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 */
long evalsum();
scalar_t__ test(char *);
long evalsh() {
  long val;
  for (val = evalsum();;) {
    if (test("<<"))
      val = val << evalsum();
    else if (test(">>"))
      val = val >> evalsum();
    else
      break;
  }
  return (val);
}


x86 assembly (clang, -O0):
<evalsh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <evalsum@plt>
mov    %rax,-0x8(%rbp)
lea    0xec6(%rip),%rdi
call   1040 <test@plt>
cmp    $0x0,%rax
je     116b <evalsh+0x4b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <evalsum@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
shl    %cl,%rax
mov    %rax,-0x8(%rbp)
jmp    11ad <evalsh+0x8d>
lea    0xe91(%rip),%rdi
call   1040 <test@plt>
cmp    $0x0,%rax
je     11a3 <evalsh+0x83>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <evalsum@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
sar    %cl,%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <evalsh+0x88>
jmp    11b2 <evalsh+0x92>
jmp    11ad <evalsh+0x8d>
jmp    1133 <evalsh+0x13>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evalsh>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <evalsum@plt>
mov    %rax,%rbx
lea    0xeca(%rip),%r14
lea    0xec6(%rip),%r15
jmp    114c <evalsh+0x2c>
nop
xor    %eax,%eax
call   1030 <evalsum@plt>
mov    %eax,%ecx
shl    %cl,%rbx
mov    %r14,%rdi
call   1040 <test@plt>
test   %rax,%rax
jne    1140 <evalsh+0x20>
mov    %r15,%rdi
call   1040 <test@plt>
test   %rax,%rax
je     1174 <evalsh+0x54>
xor    %eax,%eax
call   1030 <evalsum@plt>
mov    %eax,%ecx
sar    %cl,%rbx
jmp    114c <evalsh+0x2c>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"<<\00"
@.str.1 = [3 x i8] c">>\00"
define i64 @evalsh() {
%1 = alloca i64
%2 = call i64 (...) @evalsum()
store i64 %2, i64* %1
br label %3
3: ; preds = %19, %0
%4 = call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i64, i64* %1
%8 = call i64 (...) @evalsum()
%9 = shl i64 %7, %8
store i64 %9, i64* %1
br label %19
10: ; preds = %3
%11 = call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* %1
%15 = call i64 (...) @evalsum()
%16 = ashr i64 %14, %15
store i64 %16, i64* %1
br label %18
17: ; preds = %10
br label %20
18: ; preds = %13
br label %19
19: ; preds = %18, %6
br label %3
20: ; preds = %17
%21 = load i64, i64* %1
ret i64 %21
}

LLVM IR (-O2):
@.str = [3 x i8] c"<<\00"
@.str.1 = [3 x i8] c">>\00"
define i64 @evalsh() {
%1 = tail call i64 (...) @evalsum()
br label %2
2: ; preds = %15, %0
%3 = phi i64 [ %1, %0 ], [ %16, %15 ]
%4 = tail call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i64 (...) @evalsum()
%8 = shl i64 %3, %7
br label %15
9: ; preds = %2
%10 = tail call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = tail call i64 (...) @evalsum()
%14 = ashr i64 %3, %13
br label %15
15: ; preds = %12, %6
%16 = phi i64 [ %8, %6 ], [ %14, %12 ]
br label %2
17: ; preds = %9
ret i64 %3
}