#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 */
char CT_data(unsigned short, unsigned char *, unsigned char *, int,
             unsigned char *, unsigned short *, unsigned char *);
int /*<<< orphan*/ PrintArray(unsigned char *, unsigned short);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, unsigned int *, unsigned int *,
                         unsigned int *);
int /*<<< orphan*/ stderr;
void SendPPS(unsigned short ctn) {
  unsigned char reset[9] = {0x20, 0x11, 0x01, 0x01, 0x03,
                            0xFF, 0x00, 0x00, 0x00};
  unsigned char buffer[32], res[256];
  unsigned char dad, sad;
  unsigned short lr;
  int dummy;
  char ret;
  printf("PPS request (PPSS PPS0 PPS1): ");
  scanf("%X %X %X", (unsigned int *)buffer, (unsigned int *)(buffer + 1),
        (unsigned int *)(buffer + 2));
  dummy = getchar();
  reset[5] = buffer[0];
  reset[6] = buffer[1];
  reset[7] = buffer[2];
  dad = 0x01;
  sad = 0x02;
  lr = 256;
  printf("Command: ");
  PrintArray(reset, 8);
  ret = CT_data(ctn, &dad, &sad, 9, reset, &lr, res);
  if (ret != 0) {
    fprintf(stderr, "Error on Reset CT (Send  PPS): %d\n", ret);
    return;
  }
  printf("Response: ");
  PrintArray(res, lr);
}


x86 assembly (clang, -O0):
<SendPPS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0xb(%rbp)
mov    0xe85(%rip),%al
mov    %al,-0x3(%rbp)
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    -0x30(%rbp),%rdx
add    $0x1,%rdx
lea    -0x30(%rbp),%rcx
add    $0x2,%rcx
lea    0xe7b(%rip),%rdi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x138(%rbp)
mov    -0x30(%rbp),%al
mov    %al,-0x6(%rbp)
mov    -0x2f(%rbp),%al
mov    %al,-0x5(%rbp)
mov    -0x2e(%rbp),%al
mov    %al,-0x4(%rbp)
movb   $0x1,-0x131(%rbp)
movb   $0x2,-0x132(%rbp)
movw   $0x100,-0x134(%rbp)
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
lea    -0xb(%rbp),%rdi
mov    $0x8,%esi
call   1060 <PrintArray@plt>
mov    -0x2(%rbp),%di
lea    -0xb(%rbp),%r8
lea    -0x130(%rbp),%rax
lea    -0x131(%rbp),%rsi
lea    -0x132(%rbp),%rdx
mov    $0x9,%ecx
lea    -0x134(%rbp),%r9
movzwl %di,%edi
mov    %rax,(%rsp)
call   1080 <CT_data@plt>
mov    %al,-0x139(%rbp)
movsbl -0x139(%rbp),%eax
cmp    $0x0,%eax
je     126e <SendPPS+0x10e>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    0xdde(%rip),%rsi
movsbl -0x139(%rbp),%edx
call   1050 <fprintf@plt>
jmp    128d <SendPPS+0x12d>
lea    0xde9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x130(%rbp),%rdi
movzwl -0x134(%rbp),%esi
call   1060 <PrintArray@plt>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SendPPS>:
push   %rbp
push   %rbx
sub    $0x148,%rsp
mov    %edi,%ebp
movabs $0xff0301011120,%rax
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    0x21(%rsp),%rdx
lea    0x22(%rsp),%rcx
lea    0xe8c(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x20(%rsp),%al
mov    %al,0x15(%rsp)
movzwl 0x21(%rsp),%eax
mov    %ax,0x16(%rsp)
movb   $0x1,0xd(%rsp)
movb   $0x2,0xc(%rsp)
movw   $0x100,0xe(%rsp)
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <PrintArray@plt>
lea    0x40(%rsp),%rax
mov    %rax,(%rsp)
lea    0xd(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0xe(%rsp),%r9
mov    %ebp,%edi
mov    $0x9,%ecx
mov    %rbx,%r8
call   1080 <CT_data@plt>
test   %al,%al
je     1233 <SendPPS+0xd3>
mov    0x2dc0(%rip),%rcx
mov    (%rcx),%edi
movsbl %al,%edx
lea    0xe0f(%rip),%rsi
call   1050 <fprintf@plt>
jmp    124e <SendPPS+0xee>
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
movzwl 0xe(%rsp),%esi
lea    0x40(%rsp),%rdi
call   1060 <PrintArray@plt>
add    $0x148,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.SendPPS.reset = [9 x i8] c" \11\01\01\03\FF\00\00\00"
@.str = [31 x i8] c"PPS request (PPSS PPS0 PPS1): \00"
@.str.1 = [9 x i8] c"%X %X %X\00"
@.str.2 = [10 x i8] c"Command: \00"
@stderr = global i32 0
@.str.3 = [35 x i8] c"Error on Reset CT (Send PPS): %d\0A\00"
@.str.4 = [11 x i8] c"Response: \00"
define void @SendPPS(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [9 x i8]
%4 = alloca [32 x i8]
%5 = alloca [256 x i8]
%6 = alloca i8
%7 = alloca i8
%8 = alloca i16
%9 = alloca i32
%10 = alloca i8
store i16 %0, i16* %2
%11 = bitcast [9 x i8]* %3 to i8*
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%14 = bitcast i8* %13 to i32*
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = bitcast i8* %16 to i32*
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = bitcast i8* %19 to i32*
%21 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %14, i32* %17, i32* %20)
%22 = call i32 (...) @getchar()
store i32 %22, i32* %9
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%24 = load i8, i8* %23
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 5
store i8 %24, i8* %25
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 1
%27 = load i8, i8* %26
%28 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 6
store i8 %27, i8* %28
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 2
%30 = load i8, i8* %29
%31 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 7
store i8 %30, i8* %31
store i8 1, i8* %6
store i8 2, i8* %7
store i16 256, i16* %8
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%33 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%34 = call i32 @PrintArray(i8* %33, i16 zeroext 8)
%35 = load i16, i16* %2
%36 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%38 = call signext i8 @CT_data(i16 zeroext %35, i8* %6, i8* %7, i32 9, i8* %36, i16* %8, i8* %37)
store i8 %38, i8* %10
%39 = load i8, i8* %10
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %1
%43 = load i32, i32* @stderr
%44 = load i8, i8* %10
%45 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8 signext %44)
br label %51
46: ; preds = %1
%47 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%49 = load i16, i16* %8
%50 = call i32 @PrintArray(i8* %48, i16 zeroext %49)
br label %51
51: ; preds = %46, %42
ret void
}

LLVM IR (-O2):
@__const.SendPPS.reset = [9 x i8] c" \11\01\01\03\FF\00\00\00"
@.str = [31 x i8] c"PPS request (PPSS PPS0 PPS1): \00"
@.str.1 = [9 x i8] c"%X %X %X\00"
@.str.2 = [10 x i8] c"Command: \00"
@stderr = global i32 0
@.str.3 = [35 x i8] c"Error on Reset CT (Send PPS): %d\0A\00"
@.str.4 = [11 x i8] c"Response: \00"
define void @SendPPS(i16 zeroext %0) {
%2 = alloca [9 x i8]
%3 = alloca [32 x i8]
%4 = alloca [256 x i8]
%5 = alloca i8
%6 = alloca i8
%7 = alloca i16
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%11 = bitcast i16* %7 to i8*
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = bitcast [32 x i8]* %3 to i32*
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 1
%15 = bitcast i8* %14 to i32*
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 2
%17 = bitcast i8* %16 to i32*
%18 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32* %15, i32* %17)
%19 = call i32 (...) @getchar()
%20 = load i8, i8* %9
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 5
store i8 %20, i8* %21
%22 = load i8, i8* %14
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 6
store i8 %22, i8* %23
%24 = load i8, i8* %16
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 7
store i8 %24, i8* %25
store i8 1, i8* %5
store i8 2, i8* %6
store i16 256, i16* %7
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @PrintArray(i8* %8, i16 zeroext 8)
%28 = call signext i8 @CT_data(i16 zeroext %0, i8* %5, i8* %6, i32 9, i8* %8, i16* %7, i8* %10)
%29 = icmp eq i8 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %1
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8 signext %28)
br label %37
33: ; preds = %1
%34 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%35 = load i16, i16* %7
%36 = call i32 @PrintArray(i8* %10, i16 zeroext %35)
br label %37
37: ; preds = %33, %30
ret void
}