#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*/ usleep(int);
void brush_motor_init(void *brushmotor_address, int frequence, int duty_cycle) {
  *((volatile int *)brushmotor_address + 1) =
      frequence * 0x100000000 / 200000000;
  usleep(50);
  *((volatile int *)brushmotor_address + 2) = 0xFFFFFFFF / 100 * duty_cycle;
  usleep(50);
  *((volatile int *)brushmotor_address + 4) = 1;
  usleep(50);
  *((volatile int *)brushmotor_address + 3) = 1;
  usleep(50);
}


x86 assembly (clang, -O0):
<brush_motor_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x20,%rax
mov    $0xbebc200,%ecx
cqto
idiv   %rcx
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    $0x32,%edi
call   1030 <usleep@plt>
imul   $0x28f5c28,-0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    $0x32,%edi
call   1030 <usleep@plt>
mov    -0x8(%rbp),%rax
movl   $0x1,0x10(%rax)
mov    $0x32,%edi
call   1030 <usleep@plt>
mov    -0x8(%rbp),%rax
movl   $0x1,0xc(%rax)
mov    $0x32,%edi
call   1030 <usleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<brush_motor_init>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%eax
mov    %rdi,%rbx
shl    $0x20,%rax
movabs $0x55e63b88c230e77f,%rcx
3b e6 55
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x1a,%rdx
add    %eax,%edx
mov    %edx,0x4(%rdi)
mov    $0x32,%edi
call   1030 <usleep@plt>
imul   $0x28f5c28,%ebp,%eax
mov    %eax,0x8(%rbx)
mov    $0x32,%edi
call   1030 <usleep@plt>
movl   $0x1,0x10(%rbx)
mov    $0x32,%edi
call   1030 <usleep@plt>
movl   $0x1,0xc(%rbx)
mov    $0x32,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <usleep@plt>

LLVM IR (-O0):
define void @brush_motor_init(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = mul nsw i64 %8, 4294967296
%10 = sdiv i64 %9, 200000000
%11 = trunc i64 %10 to i32
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i32*
%14 = getelementptr inbounds i32, i32* %13, i64 1
store volatile i32 %11, i32* %14
%15 = call i32 @usleep(i32 50)
%16 = load i32, i32* %6
%17 = mul i32 42949672, %16
%18 = load i8*, i8** %4
%19 = bitcast i8* %18 to i32*
%20 = getelementptr inbounds i32, i32* %19, i64 2
store volatile i32 %17, i32* %20
%21 = call i32 @usleep(i32 50)
%22 = load i8*, i8** %4
%23 = bitcast i8* %22 to i32*
%24 = getelementptr inbounds i32, i32* %23, i64 4
store volatile i32 1, i32* %24
%25 = call i32 @usleep(i32 50)
%26 = load i8*, i8** %4
%27 = bitcast i8* %26 to i32*
%28 = getelementptr inbounds i32, i32* %27, i64 3
store volatile i32 1, i32* %28
%29 = call i32 @usleep(i32 50)
ret void
}

LLVM IR (-O2):
define void @brush_motor_init(i8* %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = shl nsw i64 %4, 32
%6 = sdiv i64 %5, 200000000
%7 = trunc i64 %6 to i32
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = bitcast i8* %8 to i32*
store volatile i32 %7, i32* %9
%10 = tail call i32 @usleep(i32 50)
%11 = mul i32 %2, 42949672
%12 = getelementptr inbounds i8, i8* %0, i64 8
%13 = bitcast i8* %12 to i32*
store volatile i32 %11, i32* %13
%14 = tail call i32 @usleep(i32 50)
%15 = getelementptr inbounds i8, i8* %0, i64 16
%16 = bitcast i8* %15 to i32*
store volatile i32 1, i32* %16
%17 = tail call i32 @usleep(i32 50)
%18 = getelementptr inbounds i8, i8* %0, i64 12
%19 = bitcast i8* %18 to i32*
store volatile i32 1, i32* %19
%20 = tail call i32 @usleep(i32 50)
ret void
}