#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int quot;
  long long rem;
};
typedef TYPE_1__ lldiv_t;

/* Variables and functions */
long long calculate_cnpj_digit(int, int);
TYPE_1__ lldiv(long long, int);
int is_cnpj(long long cnpj_l) {
  int radix, filial;
  lldiv_t division;
  division = lldiv(cnpj_l, 1000000);
  radix = division.quot;
  division = lldiv(division.rem, 100);
  filial = division.quot;
  return cnpj_l == calculate_cnpj_digit(radix, filial);
}


x86 assembly (clang, -O0):
<is_cnpj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xf4240,%esi
call   1030 <lldiv@plt>
mov    %eax,-0x30(%rbp)
mov    %rdx,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x64,%esi
call   1030 <lldiv@plt>
mov    %eax,-0x40(%rbp)
mov    %rdx,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <calculate_cnpj_digit@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_cnpj>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0xf4240,%esi
call   1030 <lldiv@plt>
mov    %eax,%ebp
mov    %rdx,%rdi
mov    $0x64,%esi
call   1030 <lldiv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <calculate_cnpj_digit@plt>
xor    %ecx,%ecx
cmp    %rbx,%rax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64 }
define i32 @is_cnpj(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.TYPE_3__
%6 = alloca %struct.TYPE_3__
%7 = alloca %struct.TYPE_3__
store i64 %0, i64* %2
%8 = load i64, i64* %2
%9 = call { i32, i64 } @lldiv(i64 %8, i32 1000000)
%10 = bitcast %struct.TYPE_3__* %6 to { i32, i64 }*
%11 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %10, i32 0, i32 0
%12 = extractvalue { i32, i64 } %9, 0
store i32 %12, i32* %11
%13 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %10, i32 0, i32 1
%14 = extractvalue { i32, i64 } %9, 1
store i64 %14, i64* %13
%15 = bitcast %struct.TYPE_3__* %5 to i8*
%16 = bitcast %struct.TYPE_3__* %6 to i8*
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %3
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 1
%20 = load i64, i64* %19
%21 = call { i32, i64 } @lldiv(i64 %20, i32 100)
%22 = bitcast %struct.TYPE_3__* %7 to { i32, i64 }*
%23 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %22, i32 0, i32 0
%24 = extractvalue { i32, i64 } %21, 0
store i32 %24, i32* %23
%25 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %22, i32 0, i32 1
%26 = extractvalue { i32, i64 } %21, 1
store i64 %26, i64* %25
%27 = bitcast %struct.TYPE_3__* %5 to i8*
%28 = bitcast %struct.TYPE_3__* %7 to i8*
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
%30 = load i32, i32* %29
store i32 %30, i32* %4
%31 = load i64, i64* %2
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = call i64 @calculate_cnpj_digit(i32 %32, i32 %33)
%35 = icmp eq i64 %31, %34
%36 = zext i1 %35 to i32
ret i32 %36
}

LLVM IR (-O2):
define i32 @is_cnpj(i64 %0) {
%2 = tail call { i32, i64 } @lldiv(i64 %0, i32 1000000)
%3 = extractvalue { i32, i64 } %2, 0
%4 = extractvalue { i32, i64 } %2, 1
%5 = tail call { i32, i64 } @lldiv(i64 %4, i32 100)
%6 = extractvalue { i32, i64 } %5, 0
%7 = tail call i64 @calculate_cnpj_digit(i32 %3, i32 %6)
%8 = icmp eq i64 %7, %0
%9 = zext i1 %8 to i32
ret i32 %9
}