int main(int argc, const char **argv) {
  signed short res;
  if (__builtin_add_overflow((signed short)0x0, (signed short)0x0, &res)) {
    return -1;
  }
  if (__builtin_add_overflow((signed short)0x7FFF, (signed short)0x0, &res)) {
    return -1;
  }
  if (__builtin_add_overflow((signed short)0x0, (signed short)0x7FFF, &res)) {
    return -1;
  }
  if (__builtin_add_overflow((signed short)0x8000, (signed short)0x7FFF,
                             &res)) {
    return -1;
  }
  if (__builtin_add_overflow((signed short)0x7FFF, (signed short)0x8000,
                             &res)) {
    return -1;
  }
  if (!__builtin_add_overflow((signed short)0x7FFF, (signed short)0x1, &res)) {
    return -1;
  }
  if (!__builtin_add_overflow((signed short)0x1, (signed short)0x7FFF, &res)) {
    return -1;
  }
  if (!__builtin_add_overflow((signed short)0x7FFF, (signed short)0x7FFF,
                              &res)) {
    return -1;
  }
  if (!__builtin_add_overflow((signed short)0x8000, (signed short)0x8000,
                              &res)) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %ax,%cx
add    $0x0,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    112f <main+0x2f>
jmp    113b <main+0x3b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
mov    $0x7fff,%cx
add    $0x0,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    1157 <main+0x57>
jmp    1163 <main+0x63>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
xor    %eax,%eax
mov    %ax,%cx
add    $0x7fff,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    1181 <main+0x81>
jmp    118d <main+0x8d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
mov    $0x8000,%cx
add    $0x7fff,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    11aa <main+0xaa>
jmp    11b6 <main+0xb6>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
mov    $0x7fff,%cx
add    $0x8000,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    11d3 <main+0xd3>
jmp    11df <main+0xdf>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
mov    $0x7fff,%cx
inc    %cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    1201 <main+0x101>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
mov    $0x1,%cx
add    $0x7fff,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    1225 <main+0x125>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
mov    $0x7fff,%cx
add    $0x7fff,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    1249 <main+0x149>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
mov    $0x8000,%cx
add    $0x8000,%cx
seto   %al
mov    %cx,-0x12(%rbp)
test   $0x1,%al
jne    126d <main+0x16d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <main+0x174>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 0, i16 0)
%8 = extractvalue { i16, i1 } %7, 1
%9 = extractvalue { i16, i1 } %7, 0
store i16 %9, i16* %6
br i1 %8, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %52
11: ; preds = %2
%12 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 32767, i16 0)
%13 = extractvalue { i16, i1 } %12, 1
%14 = extractvalue { i16, i1 } %12, 0
store i16 %14, i16* %6
br i1 %13, label %15, label %16
15: ; preds = %11
store i32 -1, i32* %3
br label %52
16: ; preds = %11
%17 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 0, i16 32767)
%18 = extractvalue { i16, i1 } %17, 1
%19 = extractvalue { i16, i1 } %17, 0
store i16 %19, i16* %6
br i1 %18, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %3
br label %52
21: ; preds = %16
%22 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 -32768, i16 32767)
%23 = extractvalue { i16, i1 } %22, 1
%24 = extractvalue { i16, i1 } %22, 0
store i16 %24, i16* %6
br i1 %23, label %25, label %26
25: ; preds = %21
store i32 -1, i32* %3
br label %52
26: ; preds = %21
%27 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 32767, i16 -32768)
%28 = extractvalue { i16, i1 } %27, 1
%29 = extractvalue { i16, i1 } %27, 0
store i16 %29, i16* %6
br i1 %28, label %30, label %31
30: ; preds = %26
store i32 -1, i32* %3
br label %52
31: ; preds = %26
%32 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 32767, i16 1)
%33 = extractvalue { i16, i1 } %32, 1
%34 = extractvalue { i16, i1 } %32, 0
store i16 %34, i16* %6
br i1 %33, label %36, label %35
35: ; preds = %31
store i32 -1, i32* %3
br label %52
36: ; preds = %31
%37 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 1, i16 32767)
%38 = extractvalue { i16, i1 } %37, 1
%39 = extractvalue { i16, i1 } %37, 0
store i16 %39, i16* %6
br i1 %38, label %41, label %40
40: ; preds = %36
store i32 -1, i32* %3
br label %52
41: ; preds = %36
%42 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 32767, i16 32767)
%43 = extractvalue { i16, i1 } %42, 1
%44 = extractvalue { i16, i1 } %42, 0
store i16 %44, i16* %6
br i1 %43, label %46, label %45
45: ; preds = %41
store i32 -1, i32* %3
br label %52
46: ; preds = %41
%47 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 -32768, i16 -32768)
%48 = extractvalue { i16, i1 } %47, 1
%49 = extractvalue { i16, i1 } %47, 0
store i16 %49, i16* %6
br i1 %48, label %51, label %50
50: ; preds = %46
store i32 -1, i32* %3
br label %52
51: ; preds = %46
store i32 0, i32* %3
br label %52
52: ; preds = %51, %50, %45, %40, %35, %30, %25, %20, %15, %10
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
ret i32 0
}