#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
void slowcat(FILE *f, int baud) {
  int ch, cps, stopbits = 1;
  if (baud == 110)
    stopbits = 2;
  cps = (baud / (sizeof(char) + 1 + stopbits));
  while ((ch = fgetc(f)) != EOF) {
    usleep(1000000 / cps);
    fputc(ch, stdout);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<slowcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x6e,-0xc(%rbp)
jne    1167 <slowcat+0x27>
movl   $0x2,-0x18(%rbp)
movslq -0xc(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    $0x2,%rcx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%eax
je     11ca <slowcat+0x8a>
mov    $0xf4240,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    117b <slowcat+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slowcat>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <fgetc@plt>
mov    0x2e8f(%rip),%r15
cmp    (%r15),%eax
je     11c7 <slowcat+0x87>
mov    %eax,%ebp
movslq %ebx,%rax
xor    %ecx,%ecx
cmp    $0x6e,%eax
sete   %cl
add    $0x3,%rcx
mov    %rax,%rdx
shr    $0x20,%rdx
je     1182 <slowcat+0x42>
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
jmp    118a <slowcat+0x4a>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%ecx
mov    $0xf4240,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,%r12d
mov    0x2e3b(%rip),%rbx
nopl   (%rax)
mov    %r12d,%edi
call   1060 <usleep@plt>
mov    (%rbx),%esi
mov    %ebp,%edi
call   1040 <fputc@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
jne    11a0 <slowcat+0x60>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@stdout = global i32 0
define void @slowcat(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 1, i32* %7
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 110
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 2, i32* %7
br label %11
11: ; preds = %10, %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = add i64 2, %15
%17 = udiv i64 %13, %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %6
br label %19
19: ; preds = %24, %11
%20 = load i32*, i32** %3
%21 = call i32 @fgetc(i32* %20)
store i32 %21, i32* %5
%22 = load i32, i32* @EOF
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = load i32, i32* %6
%26 = sdiv i32 1000000, %25
%27 = call i32 @usleep(i32 %26)
%28 = load i32, i32* %5
%29 = load i32, i32* @stdout
%30 = call i32 @fputc(i32 %28, i32 %29)
%31 = load i32, i32* @stdout
%32 = call i32 @fflush(i32 %31)
br label %19
33: ; preds = %19
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@stdout = global i32 0
define void @slowcat(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %23, label %6
6: ; preds = %2
%7 = sext i32 %1 to i64
%8 = icmp eq i32 %1, 110
%9 = select i1 %8, i64 4, i64 3
%10 = udiv i64 %7, %9
%11 = trunc i64 %10 to i32
%12 = sdiv i32 1000000, %11
br label %13
13: ; preds = %6, %13
%14 = phi i32 [ %3, %6 ], [ %20, %13 ]
%15 = tail call i32 @usleep(i32 %12)
%16 = load i32, i32* @stdout
%17 = tail call i32 @fputc(i32 %14, i32 %16)
%18 = load i32, i32* @stdout
%19 = tail call i32 @fflush(i32 %18)
%20 = tail call i32 @fgetc(i32* %0)
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %13
23: ; preds = %13, %2
ret void
}