#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void motor_drive(char *freq_l, char *freq_r) {
  FILE *motor_l, *motor_r;
  if ((motor_l = fopen("/dev/rtmotor_raw_l0", "w")) != NULL &&
      (motor_r = fopen("/dev/rtmotor_raw_r0", "w")) != NULL) {
    fputs(freq_l, motor_l);
    fputs(freq_r, motor_r);
  }
  fclose(motor_l);
  fclose(motor_r);
}


x86 assembly (clang, -O0):
<motor_drive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
lea    0xec6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     119c <motor_drive+0x6c>
lea    0xeae(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     119c <motor_drive+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<motor_drive>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xebb(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     118c <motor_drive+0x5c>
lea    0xeb6(%rip),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     118e <motor_drive+0x5e>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fputs@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
jmp    1190 <motor_drive+0x60>
jmp    1190 <motor_drive+0x60>
xor    %ebx,%ebx
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"/dev/rtmotor_raw_l0\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [20 x i8] c"/dev/rtmotor_raw_r0\00"
define void @motor_drive(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = load i32*, i32** %5
%15 = call i32 @fputs(i8* %13, i32* %14)
%16 = load i8*, i8** %4
%17 = load i32*, i32** %6
%18 = call i32 @fputs(i8* %16, i32* %17)
br label %19
19: ; preds = %12, %9, %2
%20 = load i32*, i32** %5
%21 = call i32 @fclose(i32* %20)
%22 = load i32*, i32** %6
%23 = call i32 @fclose(i32* %22)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"/dev/rtmotor_raw_l0\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [20 x i8] c"/dev/rtmotor_raw_r0\00"
define void @motor_drive(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @fputs(i8* %0, i32* %3)
%10 = tail call i32 @fputs(i8* %1, i32* %6)
br label %11
11: ; preds = %8, %5, %2
%12 = phi i32* [ %6, %8 ], [ null, %5 ], [ undef, %2 ]
%13 = tail call i32 @fclose(i32* %3)
%14 = tail call i32 @fclose(i32* %12)
ret void
}