#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*/ exit(int /*<<< orphan*/);
int gcd(int, int);
int /*<<< orphan*/ printf(char *, int, int);
int lcm(int a, int b) {
  int c;
  if ((a == 0) || (b == 0))
    return (0);
  c = gcd(a, b);
  a = a / c;
  if (a < 0) {
    printf("LCM, a = %d, b = %d\n", a, b);
    exit(0);
  }
  if (a * b < 0) {
    printf("LCM, a*b, a = %d, b = %d\n", a, b);
    exit(0);
  }
  return (a * b);
}


x86 assembly (clang, -O0):
<lcm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1152 <lcm+0x22>
cmpl   $0x0,-0xc(%rbp)
jne    115e <lcm+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11cc <lcm+0x9c>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <gcd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1199 <lcm+0x69>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cmp    $0x0,%eax
jge    11c2 <lcm+0x92>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcm>:
push   %rbp
push   %rbx
push   %rax
xor    %ecx,%ecx
test   %edi,%edi
je     115c <lcm+0x2c>
mov    %esi,%ebx
test   %esi,%esi
je     115c <lcm+0x2c>
mov    %edi,%ebp
mov    %ebx,%esi
call   1040 <gcd@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
test   %eax,%eax
js     1165 <lcm+0x35>
mov    %eax,%ecx
imul   %ebx,%ecx
test   %ecx,%ecx
js     116e <lcm+0x3e>
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe94(%rip),%rdi
jmp    1175 <lcm+0x45>
lea    0xea0(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"LCM, a = %d, b = %d\0A\00"
@.str.1 = [26 x i8] c"LCM, a*b, a = %d, b = %d\0A\00"
define i32 @lcm(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store i32 0, i32* %3
br label %41
13: ; preds = %9
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 @gcd(i32 %14, i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %4
%18 = load i32, i32* %6
%19 = sdiv i32 %17, %18
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %13
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24)
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %13
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = mul nsw i32 %28, %29
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34)
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %27
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = mul nsw i32 %38, %39
store i32 %40, i32* %3
br label %41
41: ; preds = %37, %12
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [21 x i8] c"LCM, a = %d, b = %d\0A\00"
@.str.1 = [26 x i8] c"LCM, a*b, a = %d, b = %d\0A\00"
define i32 @lcm(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
%4 = icmp eq i32 %1, 0
%5 = or i1 %3, %4
br i1 %5, label %19, label %6
6: ; preds = %2
%7 = tail call i32 @gcd(i32 %0, i32 %1)
%8 = sdiv i32 %0, %7
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %1)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %6
%14 = mul nsw i32 %8, %1
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %1)
%18 = tail call i32 @exit(i32 0)
unreachable
19: ; preds = %13, %2
%20 = phi i32 [ 0, %2 ], [ %14, %13 ]
ret i32 %20
}