#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 fmyinput(char *, char *, int);
int /*<<< orphan*/ list_user_groups(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove_user_from_grp(int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
void interactive_remusrgrp(int rid) {
  char inp[20];
  int grp, l;
  printf("\n=== REMOVE USER FROM A GROUP\n");
  list_user_groups(rid, 0);
  printf("\nPlease enter group number (for example 220), or 0 to go back\n");
  l = fmyinput("Group number? : ", inp, 16);
  sscanf(inp, "%x", &grp);
  if (!grp) {
    printf("Going back..\n");
    return;
  }
  printf("Removing user from group 0x%x (%d)\n", grp, grp);
  printf("Error messages if the user was not member of the group are "
         "harmless\n\n");
  remove_user_from_grp(rid, grp);
  printf("\nFinished removing user from group\n\n");
}


x86 assembly (clang, -O0):
<interactive_remusrgrp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1060 <list_user_groups@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xed2(%rip),%rdi
mov    $0x10,%edx
call   1030 <fmyinput@plt>
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xecb(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1070 <sscanf@plt>
cmpl   $0x0,-0x24(%rbp)
jne    11ca <interactive_remusrgrp+0x7a>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1205 <interactive_remusrgrp+0xb5>
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <remove_user_from_grp@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interactive_remusrgrp>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebp
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1070 <list_user_groups@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe70(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x10,%edx
call   1040 <fmyinput@plt>
lea    0xe68(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1080 <sscanf@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     11ee <interactive_remusrgrp+0x8e>
lea    0xe4f(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    %ebp,%edi
call   1060 <remove_user_from_grp@plt>
lea    0xefa(%rip),%rdi
jmp    11f5 <interactive_remusrgrp+0x95>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0A=== REMOVE USER FROM A GROUP\0A\00"
@.str.1 = [63 x i8] c"\0APlease enter group number (for example 220), or 0 to go back\0A\00"
@.str.2 = [17 x i8] c"Group number? : \00"
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [14 x i8] c"Going back..\0A\00"
@.str.5 = [36 x i8] c"Removing user from group 0x%x (%d)\0A\00"
@.str.6 = [70 x i8] c"Error messages if the user was not member of the group are harmless\0A\0A\00"
@.str.7 = [37 x i8] c"\0AFinished removing user from group\0A\0A\00"
define void @interactive_remusrgrp(i32 %0) {
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = call i32 @list_user_groups(i32 %7, i32 0)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = call i32 @fmyinput(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 16)
store i32 %11, i32* %5
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %27
18: ; preds = %1
%19 = load i32, i32* %4
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %19, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = call i32 @remove_user_from_grp(i32 %23, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %27
27: ; preds = %18, %16
ret void
}

LLVM IR (-O2):
@.str.2 = [17 x i8] c"Group number? : \00"
@.str.3 = [3 x i8] c"%x\00"
@.str.5 = [36 x i8] c"Removing user from group 0x%x (%d)\0A\00"
@str = [30 x i8] c"\0A=== REMOVE USER FROM A GROUP\00"
@str.8 = [62 x i8] c"\0APlease enter group number (for example 220), or 0 to go back\00"
@str.9 = [13 x i8] c"Going back..\00"
@str.10 = [69 x i8] c"Error messages if the user was not member of the group are harmless\0A\00"
@str.11 = [36 x i8] c"\0AFinished removing user from group\0A\00"
define void @interactive_remusrgrp(i32 %0) {
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @list_user_groups(i32 %0, i32 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.8, i64 0, i64 0))
%9 = call i32 @fmyinput(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32 16)
%10 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %11, i32 %11)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.10, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = call i32 @remove_user_from_grp(i32 %0, i32 %16)
br label %18
18: ; preds = %1, %13
%19 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0), %13 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0), %1 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
ret void
}