#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 /*<<< orphan*/ scanf(char *, int *, int *);
main() {
  int a, b, sm = 0;
  printf("Please enter the two numbers\n");
  scanf("%d%d", &a, &b);
  if ((a < 0) || (b < 0)) {
    if (a < 0) {
      while (a != 0) {
        sm += b;
        a++;
      }
    } else {
      while (b != 0) {
        sm += a;
        b++;
      }
    }
    printf("The answer is %d\n", (-1 * sm));
  } else {
    while (a != 0) {
      sm += b;
      a--;
    }
    printf("The answer is %d\n", sm);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     116c <main+0x4c>
cmpl   $0x0,-0xc(%rbp)
jge    11e6 <main+0xc6>
cmpl   $0x0,-0x8(%rbp)
jge    11a1 <main+0x81>
jmp    117b <main+0x5b>
cmpl   $0x0,-0x8(%rbp)
je     119c <main+0x7c>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117b <main+0x5b>
jmp    11cc <main+0xac>
jmp    11a6 <main+0x86>
cmpl   $0x0,-0xc(%rbp)
je     11c7 <main+0xa7>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a6 <main+0x86>
jmp    11cc <main+0xac>
imul   $0xffffffff,-0x10(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121d <main+0xfd>
jmp    11eb <main+0xcb>
cmpl   $0x0,-0x8(%rbp)
je     120c <main+0xec>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11eb <main+0xcb>
mov    -0x10(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1050 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%esi
test   %eax,%eax
js     1166 <main+0x36>
test   %esi,%esi
js     1166 <main+0x36>
test   %eax,%eax
jne    117b <main+0x4b>
jmp    1187 <main+0x57>
test   %eax,%eax
js     117b <main+0x4b>
test   %esi,%esi
je     1187 <main+0x57>
imul   %eax,%esi
movl   $0x0,0x4(%rsp)
jmp    1189 <main+0x59>
imul   %eax,%esi
movl   $0x0,(%rsp)
jmp    1189 <main+0x59>
xor    %esi,%esi
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Please enter the two numbers\0A\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [18 x i8] c"The answer is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %41
12: ; preds = %9, %0
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %12
br label %16
16: ; preds = %19, %15
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, %20
store i32 %22, i32* %4
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %16
25: ; preds = %16
br label %37
26: ; preds = %12
br label %27
27: ; preds = %30, %26
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i32, i32* %2
%32 = load i32, i32* %4
%33 = add nsw i32 %32, %31
store i32 %33, i32* %4
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %27
36: ; preds = %27
br label %37
37: ; preds = %36, %25
%38 = load i32, i32* %4
%39 = mul nsw i32 -1, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %54
41: ; preds = %9
br label %42
42: ; preds = %45, %41
%43 = load i32, i32* %2
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = add nsw i32 %47, %46
store i32 %48, i32* %4
%49 = load i32, i32* %2
%50 = add nsw i32 %49, -1
store i32 %50, i32* %2
br label %42
51: ; preds = %42
%52 = load i32, i32* %4
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %51, %37
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [18 x i8] c"The answer is %d\0A\00"
@str = [29 x i8] c"Please enter the two numbers\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = icmp eq i32 %7, 0
br i1 %13, label %23, label %14
14: ; preds = %12
%15 = mul i32 %9, %7
store i32 0, i32* %1
br label %23
16: ; preds = %0
br i1 %8, label %21, label %17
17: ; preds = %16
%18 = icmp eq i32 %9, 0
br i1 %18, label %23, label %19
19: ; preds = %17
%20 = mul i32 %9, %7
store i32 0, i32* %2
br label %23
21: ; preds = %16
%22 = mul i32 %7, %9
store i32 0, i32* %1
br label %23
23: ; preds = %12, %14, %21, %19, %17
%24 = phi i32 [ %22, %21 ], [ %20, %19 ], [ 0, %17 ], [ %15, %14 ], [ 0, %12 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24)
ret i32 0
}