#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 */
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int EXIT_SUCCESS;
int INT_MIN;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int impl(int, int, int, int *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ puts(char *);
int sscanf(char *, char *, int *, int *, int *);
int /*<<< orphan*/ stdin;
int main(void) {
  int overflowed;
  char buff[50];
  int a, b, c;
  printf("INT_MIN: %d\n", INT_MIN);
  do {
    puts("Enter \"a b c\"");
    fgets(buff, (sizeof(buff) / sizeof((buff)[0])), stdin);
  } while (sscanf(buff, "%d %d %d", &a, &b, &c) != 3);
  printf("a*b-c=%d overflow:%d\n", impl(a, b, c, &overflowed), overflowed);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1050 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xe77(%rip),%rsi
lea    -0x44(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1070 <sscanf@plt>
cmp    $0x3,%eax
jne    1176 <main+0x26>
mov    -0x44(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    -0x4c(%rbp),%edx
lea    -0x8(%rbp),%rcx
call   1060 <impl@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e6c(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe93(%rip),%r15
lea    0x8(%rsp),%r12
lea    0x4(%rsp),%r13
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1070 <sscanf@plt>
cmp    $0x3,%eax
jne    11a0 <main+0x50>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xc(%rsp),%rcx
call   1060 <impl@plt>
mov    0xc(%rsp),%edx
lea    0xe2f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"INT_MIN: %d\0A\00"
@INT_MIN = global i32 0
@.str.1 = [14 x i8] c"Enter \22a b c\22\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"%d %d %d\00"
@.str.3 = [22 x i8] c"a*b-c=%d overflow:%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = load i32, i32* @INT_MIN
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %14, %0
%10 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 50, i32 %12)
br label %14
14: ; preds = %9
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%17 = icmp ne i32 %16, 3
br i1 %17, label %9, label %18
18: ; preds = %14
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @impl(i32 %19, i32 %20, i32 %21, i32* %2)
%23 = load i32, i32* %2
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}

LLVM IR (-O2):
@.str = [13 x i8] c"INT_MIN: %d\0A\00"
@INT_MIN = global i32 0
@.str.1 = [14 x i8] c"Enter \22a b c\22\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"%d %d %d\00"
@.str.3 = [22 x i8] c"a*b-c=%d overflow:%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = load i32, i32* @INT_MIN
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %13, %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %7, i32 50, i32 %15)
%17 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %13
19: ; preds = %13
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = call i32 @impl(i32 %20, i32 %21, i32 %22, i32* %1)
%24 = load i32, i32* %1
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}