#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 *, int, int);
int strtol(char const *, int /*<<< orphan*/ *, int);
int handle_interrupt_reply(const char *line) {
  int i;
  int pins = strtol(line + 10, NULL, 16);
  for (i = 0; i < 16; i++) {
    if (pins & (1 << i))
      printf("received interrupt on pin P%i.%i\n", 1 + i >= 8, i % 8);
  }
  return 0;
}


x86 assembly (clang, -O0):
<handle_interrupt_reply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
add    $0xa,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    11ab <handle_interrupt_reply+0x8b>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1198 <handle_interrupt_reply+0x78>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cmp    $0x8,%eax
setge  %al
and    $0x1,%al
movzbl %al,%esi
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    119d <handle_interrupt_reply+0x7d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114c <handle_interrupt_reply+0x2c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_interrupt_reply>:
push   %rbp
push   %r14
push   %rbx
add    $0xa,%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%ebp
lea    0xec1(%rip),%r14
jmp    1158 <handle_interrupt_reply+0x38>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x10,%ebx
je     1175 <handle_interrupt_reply+0x55>
bt     %ebx,%ebp
jae    1150 <handle_interrupt_reply+0x30>
xor    %esi,%esi
cmp    $0x7,%ebx
setae  %sil
mov    %ebx,%edx
and    $0x7,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    1150 <handle_interrupt_reply+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"received interrupt on pin P%i.%i\0A\00"
define i32 @handle_interrupt_reply(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 10
%7 = call i32 @strtol(i8* %6, i32* null, i32 16)
store i32 %7, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %26, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = shl i32 1, %13
%15 = and i32 %12, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = load i32, i32* %3
%19 = add nsw i32 1, %18
%20 = icmp sge i32 %19, 8
%21 = zext i1 %20 to i32
%22 = load i32, i32* %3
%23 = srem i32 %22, 8
%24 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23)
br label %25
25: ; preds = %17, %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %8
29: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"received interrupt on pin P%i.%i\0A\00"
define i32 @handle_interrupt_reply(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 10
%3 = tail call i32 @strtol(i8* nocapture %2, i32* null, i32 16)
br label %4
4: ; preds = %1, %14
%5 = phi i32 [ 0, %1 ], [ %15, %14 ]
%6 = shl nuw nsw i32 1, %5
%7 = and i32 %6, %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = icmp ugt i32 %5, 6
%11 = zext i1 %10 to i32
%12 = and i32 %5, 7
%13 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
br label %14
14: ; preds = %4, %9
%15 = add nuw nsw i32 %5, 1
%16 = icmp eq i32 %15, 16
br i1 %16, label %17, label %4
17: ; preds = %14
ret i32 0
}