#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 O_WRONLY;
int S_IWRITE;
int open(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
void UART_Close(int UART_num, char TRX) {
  int UARTpin;
  char UARTSetAddr[50] = "/sys/devices/ocp.3/";
  char tty[15] = {
      '\0',
  };
  switch (TRX) {
  case 'T': {
    switch (UART_num) {
    case 0:
      printf("Number 0 is not export number\n");
      break;
    case 1:
      strcat(UARTSetAddr, "/P9_24_pinmux.41/state");
      break;
    case 2:
      strcat(UARTSetAddr, "/P9_21_pinmux.38/state");
      break;
    case 3:
      printf("Number T3 is not export number\n");
      break;
    case 4:
      strcat(UARTSetAddr, "/P9_13_pinmux.32/state");
      break;
    case 5:
      strcat(UARTSetAddr, "/P8_37_pinmux.26/state");
      break;
    default:
      printf("Out of export number\n");
      break;
    }
    break;
  }
  case 'R': {
    switch (UART_num) {
    case 0:
      printf("Number 0 is not export number\n");
      break;
    case 1:
      strcat(UARTSetAddr, "/P9_26_pinmux.42/state");
      break;
    case 2:
      strcat(UARTSetAddr, "/P9_22_pinmux.38/state");
      break;
    case 3:
      printf("Number R3 is not export number\n");
      break;
    case 4:
      strcat(UARTSetAddr, "/P9_11_pinmux.30/state");
      break;
    case 5:
      strcat(UARTSetAddr, "/P8_38_pinmux.27/state");
      break;
    default:
      printf("Out of export number\n");
      break;
    }
    break;
  }
  default:
    printf("Error : Input data is invalid\n");
    break;
  }
  UARTpin = open(UARTSetAddr, O_WRONLY | S_IWRITE);
  if (UARTpin > 0) {
    write(UARTpin, "default", 7);
  } else
    printf("Failed to setting UART-pinmux!\n");
  printf("Setting default : UART1\n");
}


x86 assembly (clang, -O0):
<UART_Close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movaps 0xef8(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movw   $0x0,-0x10(%rbp)
movq   $0x0,-0x49(%rbp)
movq   $0x0,-0x50(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x52,%eax
je     125a <UART_Close+0x11a>
jmp    119d <UART_Close+0x5d>
mov    -0x54(%rbp),%eax
sub    $0x54,%eax
jne    1306 <UART_Close+0x1c6>
jmp    11ae <UART_Close+0x6e>
mov    -0x4(%rbp),%eax
mov    %rax,-0x60(%rbp)
sub    $0x5,%rax
ja     1249 <UART_Close+0x109>
mov    -0x60(%rbp),%rax
lea    0xe4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
jmp    1255 <UART_Close+0x115>
lea    -0x40(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1060 <strcat@plt>
jmp    1255 <UART_Close+0x115>
lea    -0x40(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1060 <strcat@plt>
jmp    1255 <UART_Close+0x115>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
jmp    1255 <UART_Close+0x115>
lea    -0x40(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <strcat@plt>
jmp    1255 <UART_Close+0x115>
lea    -0x40(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1060 <strcat@plt>
jmp    1255 <UART_Close+0x115>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
jmp    1312 <UART_Close+0x1d2>
mov    -0x4(%rbp),%eax
mov    %rax,-0x68(%rbp)
sub    $0x5,%rax
ja     12f5 <UART_Close+0x1b5>
mov    -0x68(%rbp),%rax
lea    0xd8a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
jmp    1301 <UART_Close+0x1c1>
lea    -0x40(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1060 <strcat@plt>
jmp    1301 <UART_Close+0x1c1>
lea    -0x40(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1060 <strcat@plt>
jmp    1301 <UART_Close+0x1c1>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
jmp    1301 <UART_Close+0x1c1>
lea    -0x40(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <strcat@plt>
jmp    1301 <UART_Close+0x1c1>
lea    -0x40(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <strcat@plt>
jmp    1301 <UART_Close+0x1c1>
lea    0xe01(%rip),%rdi
call   1040 <printf@plt>
jmp    1312 <UART_Close+0x1d2>
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    0x2cb3(%rip),%rax
mov    (%rax),%esi
mov    0x2cc2(%rip),%rax
or     (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1353 <UART_Close+0x213>
mov    -0xc(%rbp),%edi
lea    0xe6a(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
jmp    135f <UART_Close+0x21f>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UART_Close>:
sub    $0x38,%rsp
movaps 0xf05(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
cmp    $0x52,%esi
je     119b <UART_Close+0x5b>
cmp    $0x54,%esi
jne    11bb <UART_Close+0x7b>
cmp    $0x5,%edi
ja     11c4 <UART_Close+0x84>
mov    %edi,%eax
lea    0xe92(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecc(%rip),%rsi
jmp    1221 <UART_Close+0xe1>
cmp    $0x5,%edi
ja     11c4 <UART_Close+0x84>
mov    %edi,%eax
lea    0xe57(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfde(%rip),%rdi
jmp    120a <UART_Close+0xca>
lea    0x1008(%rip),%rdi
jmp    120a <UART_Close+0xca>
lea    0xfea(%rip),%rdi
jmp    120a <UART_Close+0xca>
lea    0xea5(%rip),%rsi
jmp    1221 <UART_Close+0xe1>
lea    0xf9b(%rip),%rdi
jmp    120a <UART_Close+0xca>
lea    0xeaa(%rip),%rsi
jmp    1221 <UART_Close+0xe1>
lea    0xeb8(%rip),%rsi
jmp    1221 <UART_Close+0xe1>
lea    0xec6(%rip),%rsi
jmp    1221 <UART_Close+0xe1>
lea    0xed4(%rip),%rsi
jmp    1221 <UART_Close+0xe1>
lea    0xf4f(%rip),%rdi
call   1030 <puts@plt>
jmp    1229 <UART_Close+0xe9>
lea    0xed4(%rip),%rsi
jmp    1221 <UART_Close+0xe1>
lea    0xee2(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcat@plt>
mov    0x2da0(%rip),%rax
mov    0x2db1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rsp,%rdi
call   1050 <open@plt>
test   %eax,%eax
jle    125c <UART_Close+0x11c>
lea    0xecc(%rip),%rsi
mov    %eax,%edi
mov    $0x7,%edx
call   1040 <write@plt>
jmp    1268 <UART_Close+0x128>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.UART_Close.UARTSetAddr = [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"
@.str = [31 x i8] c"Number 0 is not export number\0A\00"
@.str.1 = [23 x i8] c"/P9_24_pinmux.41/state\00"
@.str.2 = [23 x i8] c"/P9_21_pinmux.38/state\00"
@.str.3 = [32 x i8] c"Number T3 is not export number\0A\00"
@.str.4 = [23 x i8] c"/P9_13_pinmux.32/state\00"
@.str.5 = [23 x i8] c"/P8_37_pinmux.26/state\00"
@.str.6 = [22 x i8] c"Out of export number\0A\00"
@.str.7 = [23 x i8] c"/P9_26_pinmux.42/state\00"
@.str.8 = [23 x i8] c"/P9_22_pinmux.38/state\00"
@.str.9 = [32 x i8] c"Number R3 is not export number\0A\00"
@.str.10 = [23 x i8] c"/P9_11_pinmux.30/state\00"
@.str.11 = [23 x i8] c"/P8_38_pinmux.27/state\00"
@.str.12 = [31 x i8] c"Error : Input data is invalid\0A\00"
@O_WRONLY = global i32 0
@S_IWRITE = global i32 0
@.str.13 = [8 x i8] c"default\00"
@.str.14 = [32 x i8] c"Failed to setting UART-pinmux!\0A\00"
@.str.15 = [25 x i8] c"Setting default : UART1\0A\00"
define void @UART_Close(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca [50 x i8]
%7 = alloca [15 x i8]
store i32 %0, i32* %3
store i8 %1, i8* %4
%8 = bitcast [50 x i8]* %6 to i8*
%9 = bitcast [15 x i8]* %7 to i8*
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
switch i32 %11, label %54 [
i32 84, label %12
i32 82, label %33
]
12: ; preds = %2
%13 = load i32, i32* %3
switch i32 %13, label %30 [
i32 0, label %14
i32 1, label %16
i32 2, label %19
i32 3, label %22
i32 4, label %24
i32 5, label %27
]
14: ; preds = %12
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %32
16: ; preds = %12
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %32
19: ; preds = %12
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %32
22: ; preds = %12
%23 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %32
24: ; preds = %12
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %32
27: ; preds = %12
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %32
30: ; preds = %12
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %30, %27, %24, %22, %19, %16, %14
br label %56
33: ; preds = %2
%34 = load i32, i32* %3
switch i32 %34, label %51 [
i32 0, label %35
i32 1, label %37
i32 2, label %40
i32 3, label %43
i32 4, label %45
i32 5, label %48
]
35: ; preds = %33
%36 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %53
37: ; preds = %33
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %53
40: ; preds = %33
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %53
43: ; preds = %33
%44 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %53
45: ; preds = %33
%46 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
br label %53
48: ; preds = %33
%49 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%50 = call i32 @strcat(i8* %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
br label %53
51: ; preds = %33
%52 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %53
53: ; preds = %51, %48, %45, %43, %40, %37, %35
br label %56
54: ; preds = %2
%55 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0))
br label %56
56: ; preds = %54, %53, %32
%57 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%58 = load i32, i32* @O_WRONLY
%59 = load i32, i32* @S_IWRITE
%60 = or i32 %58, %59
%61 = call i32 @open(i8* %57, i32 %60)
store i32 %61, i32* %5
%62 = load i32, i32* %5
%63 = icmp sgt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %56
%65 = load i32, i32* %5
%66 = call i32 @write(i32 %65, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i32 7)
br label %69
67: ; preds = %56
%68 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
br label %69
69: ; preds = %67, %64
%70 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.UART_Close.UARTSetAddr = [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"
@.str.1 = [23 x i8] c"/P9_24_pinmux.41/state\00"
@.str.2 = [23 x i8] c"/P9_21_pinmux.38/state\00"
@.str.4 = [23 x i8] c"/P9_13_pinmux.32/state\00"
@.str.5 = [23 x i8] c"/P8_37_pinmux.26/state\00"
@.str.7 = [23 x i8] c"/P9_26_pinmux.42/state\00"
@.str.8 = [23 x i8] c"/P9_22_pinmux.38/state\00"
@.str.10 = [23 x i8] c"/P9_11_pinmux.30/state\00"
@.str.11 = [23 x i8] c"/P8_38_pinmux.27/state\00"
@O_WRONLY = global i32 0
@S_IWRITE = global i32 0
@.str.13 = [8 x i8] c"default\00"
@str = [31 x i8] c"Failed to setting UART-pinmux!\00"
@str.16 = [24 x i8] c"Setting default : UART1\00"
@str.17 = [31 x i8] c"Number R3 is not export number\00"
@str.20 = [31 x i8] c"Number T3 is not export number\00"
@str.21 = [30 x i8] c"Number 0 is not export number\00"
@str.22 = [21 x i8] c"Out of export number\00"
@str.23 = [30 x i8] c"Error : Input data is invalid\00"
define void @UART_Close(i32 %0, i8 signext %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = sext i8 %1 to i32
switch i32 %5, label %36 [
i32 84, label %6
i32 82, label %21
]
6: ; preds = %2
switch i32 %0, label %19 [
i32 0, label %7
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %15
i32 5, label %17
]
7: ; preds = %6
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.21, i64 0, i64 0))
br label %38
9: ; preds = %6
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %38
11: ; preds = %6
%12 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %38
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.20, i64 0, i64 0))
br label %38
15: ; preds = %6
%16 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %38
17: ; preds = %6
%18 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %38
19: ; preds = %6
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.22, i64 0, i64 0))
br label %38
21: ; preds = %2
switch i32 %0, label %34 [
i32 0, label %22
i32 1, label %24
i32 2, label %26
i32 3, label %28
i32 4, label %30
i32 5, label %32
]
22: ; preds = %21
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.21, i64 0, i64 0))
br label %38
24: ; preds = %21
%25 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %38
26: ; preds = %21
%27 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %38
28: ; preds = %21
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.17, i64 0, i64 0))
br label %38
30: ; preds = %21
%31 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
br label %38
32: ; preds = %21
%33 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
br label %38
34: ; preds = %21
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.22, i64 0, i64 0))
br label %38
36: ; preds = %2
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.23, i64 0, i64 0))
br label %38
38: ; preds = %22, %24, %26, %28, %30, %32, %34, %7, %9, %11, %13, %15, %17, %19, %36
%39 = load i32, i32* @O_WRONLY
%40 = load i32, i32* @S_IWRITE
%41 = or i32 %40, %39
%42 = call i32 @open(i8* %4, i32 %41)
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 @write(i32 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i32 7)
br label %48
46: ; preds = %38
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0))
ret void
}