#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 error(int, char *);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ zaber_set_current_position(unsigned char, int);
int cmd_zsetpos(int argc, char *argv[]) {
  unsigned char unit;
  int posn;
  if (argc != 3)
    return error((-2), "Usage: zsetposn [unit] [posn]");
  sscanf(argv[1], "%hhu", &unit);
  sscanf(argv[2], "%d", &posn);
  zaber_set_current_position(unit, posn);
  return 0;
}


x86 assembly (clang, -O0):
<cmd_zsetpos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1162 <cmd_zsetpos+0x32>
mov    $0xfffffffe,%edi
lea    0xeab(%rip),%rsi
call   1050 <error@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <cmd_zsetpos+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xead(%rip),%rsi
lea    -0x11(%rbp),%rdx
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe98(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%esi
movzbl %al,%edi
call   1040 <zaber_set_current_position@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_zsetpos>:
cmp    $0x3,%edi
jne    1181 <cmd_zsetpos+0x51>
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xed6(%rip),%rsi
lea    0xb(%rsp),%rdx
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    0x10(%rbx),%rdi
lea    0xec4(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1030 <sscanf@plt>
movzbl 0xb(%rsp),%edi
mov    0xc(%rsp),%esi
call   1040 <zaber_set_current_position@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe78(%rip),%rsi
mov    $0xfffffffe,%edi
jmp    1050 <error@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Usage: zsetposn [unit] [posn]\00"
@.str.1 = [5 x i8] c"%hhu\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @cmd_zsetpos(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @error(i32 -2, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %3
br label %24
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 (i8*, i8*, ...) @sscanf(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i8*, ...) @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%21 = load i8, i8* %6
%22 = load i32, i32* %7
%23 = call i32 @zaber_set_current_position(i8 zeroext %21, i32 %22)
store i32 0, i32* %3
br label %24
24: ; preds = %12, %10
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [30 x i8] c"Usage: zsetposn [unit] [posn]\00"
@.str.1 = [5 x i8] c"%hhu\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @cmd_zsetpos(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = icmp eq i32 %0, 3
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @error(i32 -2, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %19
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 (i8*, i8*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, ...) @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%16 = load i8, i8* %3
%17 = load i32, i32* %4
%18 = call i32 @zaber_set_current_position(i8 zeroext %16, i32 %17)
br label %19
19: ; preds = %9, %7
%20 = phi i32 [ %8, %7 ], [ 0, %9 ]
ret i32 %20
}