#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, int, int);
int calcOutputSize(int length, int padding, int filter_length, int stride) {
  int tmp = length - filter_length + padding * 2;
  if (tmp % stride != 0) {
    printf("ERROR: Illegal input size or stride settings: Input length = %d, "
           "filter length = %d, stride = %d\n",
           length, filter_length, stride);
    return 0;
  } else {
    return tmp / stride + 1;
  }
}


x86 assembly (clang, -O0):
<calcOutputSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
je     1166 <calcOutputSize+0x56>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1173 <calcOutputSize+0x63>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcOutputSize>:
mov    %edx,%r8d
mov    %edi,%eax
sub    %edx,%eax
lea    (%rax,%rsi,2),%eax
cltd
idiv   %ecx
test   %edx,%edx
je     113e <calcOutputSize+0x2e>
push   %rax
mov    %edi,%r9d
lea    0xed4(%rip),%rdi
mov    %r9d,%esi
mov    %r8d,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret
add    $0x1,%eax
ret

LLVM IR (-O0):
@.str = [98 x i8] c"ERROR: Illegal input size or stride settings: Input length = %d, filter length = %d, stride = %d\0A\00"
define i32 @calcOutputSize(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %6
%12 = load i32, i32* %8
%13 = sub nsw i32 %11, %12
%14 = load i32, i32* %7
%15 = mul nsw i32 %14, 2
%16 = add nsw i32 %13, %15
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = load i32, i32* %9
%19 = srem i32 %17, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %4
%22 = load i32, i32* %6
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
store i32 0, i32* %5
br label %31
26: ; preds = %4
%27 = load i32, i32* %10
%28 = load i32, i32* %9
%29 = sdiv i32 %27, %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %31
31: ; preds = %26, %21
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
@.str = [98 x i8] c"ERROR: Illegal input size or stride settings: Input length = %d, filter length = %d, stride = %d\0A\00"
define i32 @calcOutputSize(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %0, %2
%6 = shl nsw i32 %1, 1
%7 = add nsw i32 %5, %6
%8 = srem i32 %7, %3
%9 = sdiv i32 %7, %3
%10 = icmp eq i32 %8, 0
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = tail call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %2, i32 %3)
br label %15
13: ; preds = %4
%14 = add nsw i32 %9, 1
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ 0, %11 ], [ %14, %13 ]
ret i32 %16
}