#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 validate_d(long e, long phi_f, long *d) {
  printf("Validating d ... ");
  if ((*d * e) % phi_f) {
    printf("Ok.\n");
    return 1;
  } else {
    printf("Error.\n");
    return -1;
  }
}


x86 assembly (clang, -O0):
<validate_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
imul   -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
je     1164 <validate_d+0x54>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1177 <validate_d+0x67>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_d>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
imul   (%r15),%rbx
mov    %rbx,%rax
or     %r14,%rax
shr    $0x20,%rax
je     1154 <validate_d+0x34>
mov    %rbx,%rax
cqto
idiv   %r14
jmp    115b <validate_d+0x3b>
mov    %ebx,%eax
xor    %edx,%edx
div    %r14d
test   %rdx,%rdx
lea    0xead(%rip),%rax
lea    0xead(%rip),%rdi
cmove  %rax,%rdi
cmp    $0x1,%rdx
sbb    %ebx,%ebx
or     $0x1,%ebx
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Validating d ... \00"
@.str.1 = [5 x i8] c"Ok.\0A\00"
@.str.2 = [8 x i8] c"Error.\0A\00"
define i32 @validate_d(i64 %0, i64 %1, i64* %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64*
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64* %2, i64** %7
%8 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = load i64*, i64** %7
%10 = load i64, i64* %9
%11 = load i64, i64* %5
%12 = mul nsw i64 %10, %11
%13 = load i64, i64* %6
%14 = srem i64 %12, %13
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %20
18: ; preds = %3
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %20
20: ; preds = %18, %16
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
@.str = [18 x i8] c"Validating d ... \00"
@str = [7 x i8] c"Error.\00"
@str.3 = [4 x i8] c"Ok.\00"
define i32 @validate_d(i64 %0, i64 %1, i64* nocapture %2) {
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = load i64, i64* %2
%6 = mul nsw i64 %5, %0
%7 = srem i64 %6, %1
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0)
%10 = select i1 %8, i32 -1, i32 1
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %10
}