#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*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
char *strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int InitPWM(int PWM_num) {
  FILE *PWM_set_addr;
  FILE *PWM_export;
  char PWM_pin_addr1[50] = "/sys/devices/ocp.3";
  char PWM_pin_addr2[25] = {
      '\0',
  };
  char PWM_pin_num[5] = {
      '\0',
  };
  switch (PWM_num) {
  case 0:
    strcpy(PWM_pin_addr2, "/P9_29_pinmux.44");
    break;
  case 1:
    strcpy(PWM_pin_addr2, "/P9_31_pinmux.46");
    break;
  case 3:
    strcpy(PWM_pin_addr2, "/P9_14_pinmux.33");
    break;
  case 4:
    strcpy(PWM_pin_addr2, "/P9_16_pinmux.35");
    break;
  case 5:
    strcpy(PWM_pin_addr2, "/P8_45_pinmux.28");
    break;
  case 6:
    strcpy(PWM_pin_addr2, "/P8_46_pinmux.29");
    break;
  default:
    printf("Error!\n");
    break;
  }
  strcat(PWM_pin_addr1, strcat(PWM_pin_addr2, "/state"));
  PWM_set_addr = fopen(PWM_pin_addr1, "w");
  if (PWM_set_addr == NULL)
    printf("Init_PWM failed to setting");
  fseek(PWM_set_addr, 0, SEEK_SET);
  fprintf(PWM_set_addr, "pwm");
  printf("pwm > %s\n", PWM_pin_addr1);
  fflush(PWM_set_addr);
  fclose(PWM_set_addr);
  PWM_export = fopen("/sys/class/pwm/export", "w");
  if (PWM_export == NULL)
    printf("Init_PWM failed to export");
  sprintf(PWM_pin_num, "%i", PWM_num);
  fprintf(PWM_export, PWM_pin_num);
  fflush(PWM_export);
  fclose(PWM_export);
  return 1;
}


x86 assembly (clang, -O0):
<InitPWM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movaps 0xe80(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movaps 0xe65(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
movw   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movups %xmm0,-0x67(%rbp)
movaps %xmm0,-0x70(%rbp)
movb   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x80(%rbp)
sub    $0x6,%rax
ja     127e <InitPWM+0xee>
mov    -0x80(%rbp),%rax
lea    0xe09(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x70(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128c <InitPWM+0xfc>
lea    -0x70(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128c <InitPWM+0xfc>
lea    -0x70(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128c <InitPWM+0xfc>
lea    -0x70(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128c <InitPWM+0xfc>
lea    -0x70(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128c <InitPWM+0xfc>
lea    -0x70(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1030 <strcpy@plt>
jmp    128c <InitPWM+0xfc>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x88(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12e3 <InitPWM+0x153>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2cf2(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x10(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x50(%rbp),%rsi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <fflush@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdc0(%rip),%rdi
lea    0xd8e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    135b <InitPWM+0x1cb>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x78(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xdb9(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fflush@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InitPWM>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %edi,%r14d
movaps 0xe6e(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe52(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe36(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movw   $0x0,0x60(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x19(%rsp)
movaps %xmm0,0x10(%rsp)
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
cmp    $0x6,%edi
ja     123a <InitPWM+0x7a>
mov    %r14d,%eax
lea    0xde1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe23(%rip),%rsi
jmp    126a <InitPWM+0xaa>
lea    0xe2b(%rip),%rsi
jmp    126a <InitPWM+0xaa>
lea    0xedc(%rip),%rdi
call   1040 <puts@plt>
jmp    1274 <InitPWM+0xb4>
lea    0xe25(%rip),%rsi
jmp    126a <InitPWM+0xaa>
lea    0xe2d(%rip),%rsi
jmp    126a <InitPWM+0xaa>
lea    0xe35(%rip),%rsi
jmp    126a <InitPWM+0xaa>
lea    0xe3d(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
movl   $0x6174732f,0x10(%rsp,%rax,1)
61
movl   $0x657461,0x13(%rsp,%rax,1)
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xe17(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    12c6 <InitPWM+0x106>
lea    0xe02(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
lea    0xdfc(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xde7(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1090 <fflush@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xdce(%rip),%rdi
lea    0xd9c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    133e <InitPWM+0x17e>
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd5(%rip),%rsi
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1090 <fflush@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.InitPWM.PWM_pin_addr1 = [50 x i8] c"/sys/devices/ocp.3\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [17 x i8] c"/P9_29_pinmux.44\00"
@.str.1 = [17 x i8] c"/P9_31_pinmux.46\00"
@.str.2 = [17 x i8] c"/P9_14_pinmux.33\00"
@.str.3 = [17 x i8] c"/P9_16_pinmux.35\00"
@.str.4 = [17 x i8] c"/P8_45_pinmux.28\00"
@.str.5 = [17 x i8] c"/P8_46_pinmux.29\00"
@.str.6 = [8 x i8] c"Error!\0A\00"
@.str.7 = [7 x i8] c"/state\00"
@.str.8 = [2 x i8] c"w\00"
@.str.9 = [27 x i8] c"Init_PWM failed to setting\00"
@SEEK_SET = global i32 0
@.str.10 = [4 x i8] c"pwm\00"
@.str.11 = [10 x i8] c"pwm > %s\0A\00"
@.str.12 = [22 x i8] c"/sys/class/pwm/export\00"
@.str.13 = [26 x i8] c"Init_PWM failed to export\00"
@.str.14 = [3 x i8] c"%i\00"
define i32 @InitPWM(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [50 x i8]
%6 = alloca [25 x i8]
%7 = alloca [5 x i8]
store i32 %0, i32* %2
%8 = bitcast [50 x i8]* %5 to i8*
%9 = bitcast [25 x i8]* %6 to i8*
%10 = bitcast [5 x i8]* %7 to i8*
%11 = load i32, i32* %2
switch i32 %11, label %30 [
i32 0, label %12
i32 1, label %15
i32 3, label %18
i32 4, label %21
i32 5, label %24
i32 6, label %27
]
12: ; preds = %1
%13 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %32
15: ; preds = %1
%16 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %32
18: ; preds = %1
%19 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %32
21: ; preds = %1
%22 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %32
24: ; preds = %1
%25 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %32
27: ; preds = %1
%28 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %32
30: ; preds = %1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %30, %27, %24, %21, %18, %15, %12
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%35 = call i8* @strcat(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%36 = call i8* @strcat(i8* %33, i8* %35)
%37 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %38, i32** %3
%39 = load i32*, i32** %3
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %43
41: ; preds = %32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
br label %43
43: ; preds = %41, %32
%44 = load i32*, i32** %3
%45 = load i32, i32* @SEEK_SET
%46 = call i32 @fseek(i32* %44, i32 0, i32 %45)
%47 = load i32*, i32** %3
%48 = call i32 @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%49 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %49)
%51 = load i32*, i32** %3
%52 = call i32 @fflush(i32* %51)
%53 = load i32*, i32** %3
%54 = call i32 @fclose(i32* %53)
%55 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %55, i32** %4
%56 = load i32*, i32** %4
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %60
58: ; preds = %43
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %60
60: ; preds = %58, %43
%61 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%62 = load i32, i32* %2
%63 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32 %62)
%64 = load i32*, i32** %4
%65 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%66 = call i32 @fprintf(i32* %64, i8* %65)
%67 = load i32*, i32** %4
%68 = call i32 @fflush(i32* %67)
%69 = load i32*, i32** %4
%70 = call i32 @fclose(i32* %69)
ret i32 1
}

LLVM IR (-O2):
@__const.InitPWM.PWM_pin_addr1 = [50 x i8] c"/sys/devices/ocp.3\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [17 x i8] c"/P9_29_pinmux.44\00"
@.str.1 = [17 x i8] c"/P9_31_pinmux.46\00"
@.str.2 = [17 x i8] c"/P9_14_pinmux.33\00"
@.str.3 = [17 x i8] c"/P9_16_pinmux.35\00"
@.str.4 = [17 x i8] c"/P8_45_pinmux.28\00"
@.str.5 = [17 x i8] c"/P8_46_pinmux.29\00"
@.str.7 = [7 x i8] c"/state\00"
@.str.8 = [2 x i8] c"w\00"
@.str.9 = [27 x i8] c"Init_PWM failed to setting\00"
@SEEK_SET = global i32 0
@.str.10 = [4 x i8] c"pwm\00"
@.str.11 = [10 x i8] c"pwm > %s\0A\00"
@.str.12 = [22 x i8] c"/sys/class/pwm/export\00"
@.str.13 = [26 x i8] c"Init_PWM failed to export\00"
@.str.14 = [3 x i8] c"%i\00"
@str = [7 x i8] c"Error!\00"
define i32 @InitPWM(i32 %0) {
%2 = alloca [50 x i8]
%3 = alloca [25 x i8]
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
switch i32 %0, label %20 [
i32 0, label %8
i32 1, label %10
i32 3, label %12
i32 4, label %14
i32 5, label %16
i32 6, label %18
]
8: ; preds = %1
%9 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %22
10: ; preds = %1
%11 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %22
12: ; preds = %1
%13 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %22
14: ; preds = %1
%15 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %22
16: ; preds = %1
%17 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %22
18: ; preds = %1
%19 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %22
20: ; preds = %1
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %18, %16, %14, %12, %10, %8
%23 = call i64 @strlen(i8* %6)
%24 = getelementptr [25 x i8], [25 x i8]* %3, i64 0, i64 %23
%25 = call i8* @strcat(i8* %5, i8* %6)
%26 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %26, i32 0, i32 %31)
%33 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i64 3, i64 1, i32* %26)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %5)
%35 = call i32 @fflush(i32* %26)
%36 = call i32 @fclose(i32* %26)
%37 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %41
39: ; preds = %30
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %41
41: ; preds = %39, %30
%42 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i32 %0)
%43 = call i32 @fprintf(i32* %37, i8* %7)
%44 = call i32 @fflush(i32* %37)
%45 = call i32 @fclose(i32* %37)
ret i32 1
}