#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*/ addition(char *, char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
void addition_signed(char *a, char *b, char *s) {
  addition(a, b, s);
  if (a[0] == b[0]) {
    if ((a[0] == 0) && (s[0] == 1)) {
      fprintf(stderr, "overflow detected: %s\n", s);
      exit(2);
    }
    if ((a[0] == 1) && (s[0] = 0)) {
      fprintf(stderr, "overflow detected: %s\n", s);
      exit(2);
    }
  }
}


x86 assembly (clang, -O0):
<addition_signed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <addition@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11fc <addition_signed+0xcc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ae <addition_signed+0x7e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1,%eax
jne    11ae <addition_signed+0x7e>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe61(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1,%eax
jne    11f7 <addition_signed+0xc7>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
test   $0x1,%al
jne    11d4 <addition_signed+0xa4>
jmp    11f7 <addition_signed+0xc7>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe18(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
jmp    11fc <addition_signed+0xcc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addition_signed>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <addition@plt>
mov    (%rbx),%al
cmp    (%r15),%al
jne    117e <addition_signed+0x4e>
cmp    $0x1,%al
je     117a <addition_signed+0x4a>
test   %al,%al
jne    117e <addition_signed+0x4e>
cmpb   $0x1,(%r14)
jne    117e <addition_signed+0x4e>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
movb   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"overflow detected: %s\0A\00"
define void @addition_signed(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = load i8*, i8** %6
%10 = call i32 @addition(i8* %7, i8* %8, i8* %9)
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %14, %18
br i1 %19, label %20, label %52
20: ; preds = %3
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %20
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %37
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %6
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 2)
unreachable
37: ; preds = %26, %20
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %51
43: ; preds = %37
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 0
store i8 0, i8* %45
br i1 false, label %46, label %51
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = load i8*, i8** %6
%49 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %48)
%50 = call i32 @exit(i32 2)
unreachable
51: ; preds = %43, %37
br label %52
52: ; preds = %51, %3
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"overflow detected: %s\0A\00"
define void @addition_signed(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @addition(i8* %0, i8* %1, i8* %2)
%5 = load i8, i8* %0
%6 = load i8, i8* %1
%7 = icmp eq i8 %5, %6
br i1 %7, label %8, label %17
8: ; preds = %3
switch i8 %5, label %17 [
i8 0, label %9
i8 1, label %16
]
9: ; preds = %8
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %2)
%15 = tail call i32 @exit(i32 2)
unreachable
16: ; preds = %8
store i8 0, i8* %2
br label %17
17: ; preds = %8, %9, %16, %3
ret void
}