#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*/ SIGINT;
int /*<<< orphan*/ __mriCore_FlagSemihostCallAsHandled();
int /*<<< orphan*/ __mriCore_GdbCommandHandlingLoop();
int /*<<< orphan*/ __mriCore_SetSignalValue(int /*<<< orphan*/);
scalar_t__ __mriCore_WasControlCFlagSentFromGdb();
int /*<<< orphan*/ __mriCore_WasSemihostCallCancelledByGdb();
int processGdbFileResponseCommands(void) {
  __mriCore_GdbCommandHandlingLoop();
  if (__mriCore_WasControlCFlagSentFromGdb()) {
    if (!__mriCore_WasSemihostCallCancelledByGdb())
      __mriCore_FlagSemihostCallAsHandled();
    __mriCore_SetSignalValue(SIGINT);
    return 0;
  } else {
    __mriCore_FlagSemihostCallAsHandled();
    return 1;
  }
}


x86 assembly (clang, -O0):
<processGdbFileResponseCommands>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <__mriCore_GdbCommandHandlingLoop@plt>
mov    $0x0,%al
call   1040 <__mriCore_WasControlCFlagSentFromGdb@plt>
cmp    $0x0,%rax
je     11a1 <processGdbFileResponseCommands+0x51>
mov    $0x0,%al
call   1050 <__mriCore_WasSemihostCallCancelledByGdb@plt>
cmp    $0x0,%eax
jne    1187 <processGdbFileResponseCommands+0x37>
mov    $0x0,%al
call   1070 <__mriCore_FlagSemihostCallAsHandled@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1060 <__mriCore_SetSignalValue@plt>
movl   $0x0,-0x4(%rbp)
jmp    11af <processGdbFileResponseCommands+0x5f>
mov    $0x0,%al
call   1070 <__mriCore_FlagSemihostCallAsHandled@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processGdbFileResponseCommands>:
push   %rbx
xor    %eax,%eax
call   1030 <__mriCore_GdbCommandHandlingLoop@plt>
xor    %eax,%eax
call   1040 <__mriCore_WasControlCFlagSentFromGdb@plt>
test   %rax,%rax
je     1188 <processGdbFileResponseCommands+0x38>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <__mriCore_WasSemihostCallCancelledByGdb@plt>
test   %eax,%eax
jne    1178 <processGdbFileResponseCommands+0x28>
xor    %eax,%eax
call   1070 <__mriCore_FlagSemihostCallAsHandled@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1060 <__mriCore_SetSignalValue@plt>
jmp    1194 <processGdbFileResponseCommands+0x44>
xor    %eax,%eax
call   1070 <__mriCore_FlagSemihostCallAsHandled@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@SIGINT = global i32 0
define i32 @processGdbFileResponseCommands() {
%1 = alloca i32
%2 = call i32 (...) @__mriCore_GdbCommandHandlingLoop()
%3 = call i64 (...) @__mriCore_WasControlCFlagSentFromGdb()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %0
%6 = call i32 (...) @__mriCore_WasSemihostCallCancelledByGdb()
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = call i32 (...) @__mriCore_FlagSemihostCallAsHandled()
br label %10
10: ; preds = %8, %5
%11 = load i32, i32* @SIGINT
%12 = call i32 @__mriCore_SetSignalValue(i32 %11)
store i32 0, i32* %1
br label %15
13: ; preds = %0
%14 = call i32 (...) @__mriCore_FlagSemihostCallAsHandled()
store i32 1, i32* %1
br label %15
15: ; preds = %13, %10
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@SIGINT = global i32 0
define i32 @processGdbFileResponseCommands() {
%1 = tail call i32 (...) @__mriCore_GdbCommandHandlingLoop()
%2 = tail call i64 (...) @__mriCore_WasControlCFlagSentFromGdb()
%3 = icmp eq i64 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %0
%5 = tail call i32 (...) @__mriCore_WasSemihostCallCancelledByGdb()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 (...) @__mriCore_FlagSemihostCallAsHandled()
br label %9
9: ; preds = %7, %4
%10 = load i32, i32* @SIGINT
%11 = tail call i32 @__mriCore_SetSignalValue(i32 %10)
br label %14
12: ; preds = %0
%13 = tail call i32 (...) @__mriCore_FlagSemihostCallAsHandled()
br label %14
14: ; preds = %12, %9
%15 = phi i32 [ 0, %9 ], [ 1, %12 ]
ret i32 %15
}